Etienne Robillard
How to disable fastcgi caching for the logged user?
August 05, 2017 08:50PM
Hi,

I'm testing a OAuth2 middleware on my python web app and would like to
disable fastcgi caching when the fastcgi variable REMOTE_USER is set.

Is there any ways of doing this from nginx?

Thanks in advance,

Etienne


--
Etienne Robillard
tkadm30@yandex.com
http://www.isotopesoftware.ca/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Etienne Robillard
Re: How to disable fastcgi caching for the logged user?
August 05, 2017 09:30PM
The $http_pragma is not properly defined in
http://nginx.org/en/docs/varindex.html

Is that a custom variable or is defined in nginx?

I was hoping of doing something like:

fastcgi_no_cache $http_pragma $remote_user;

What do you think?

E

Le 2017-08-05 à 14:42, Etienne Robillard a écrit :
> Hi,
>
> I'm testing a OAuth2 middleware on my python web app and would like to
> disable fastcgi caching when the fastcgi variable REMOTE_USER is set.
>
> Is there any ways of doing this from nginx?
>
> Thanks in advance,
>
> Etienne
>
>

--
Etienne Robillard
tkadm30@yandex.com
http://www.isotopesoftware.ca/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Francis Daly
Re: How to disable fastcgi caching for the logged user?
August 06, 2017 11:50AM
On Sat, Aug 05, 2017 at 03:24:28PM -0400, Etienne Robillard wrote:

Hi there,

> The $http_pragma is not properly defined in
> http://nginx.org/en/docs/varindex.html

It's the one after "$http2" and before "$https".

> Is that a custom variable or is defined in nginx?

$http_anything is defined in nginx if the incoming request has a header
that maps to "anything".

> I was hoping of doing something like:
>
> fastcgi_no_cache $http_pragma $remote_user;
>
> What do you think?

The documentation at http://nginx.org/r/fastcgi_no_cache describes what
that directive should do.

You want to disable fastcgi caching when the fastcgi variable REMOTE_USER
is set.

Your config presumably includes something like "fastcgi_param REMOTE_USER
$something".

In that case, you want "fastcgi_no_cache $something".

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Etienne Robillard
Re: How to disable fastcgi caching for the logged user?
August 07, 2017 10:50AM
Hi Francis,

Thank you for your reply. What is the difference between:

fastcgi_no_cache $http_pragma $http_authorization

and

fastcgi_no_cache $remote_user

?

In addition, how can I verify the configuration is working as expected?

Thanks,

E


Le 2017-08-06 à 05:48, Francis Daly a écrit :
>
> The documentation at http://nginx.org/r/fastcgi_no_cache describes what
> that directive should do.
>
> You want to disable fastcgi caching when the fastcgi variable REMOTE_USER
> is set.
>
> Your config presumably includes something like "fastcgi_param REMOTE_USER
> $something".
>
> In that case, you want "fastcgi_no_cache $something".


> Good luck with it,
>
> f

--
Etienne Robillard
tkadm30@yandex.com
http://www.isotopesoftware.ca/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Francis Daly
Re: How to disable fastcgi caching for the logged user?
August 08, 2017 08:40PM
On Mon, Aug 07, 2017 at 04:47:30AM -0400, Etienne Robillard wrote:

Hi there,

> Thank you for your reply. What is the difference between:
>
> fastcgi_no_cache $http_pragma $http_authorization
>
> and
>
> fastcgi_no_cache $remote_user

http://nginx.org/r/fastcgi_no_cache
http://nginx.org/r/$http_
http://nginx.org/r/$remote_user

In each case, if the request is handled by a fastcgi_pass, then the
response will[*] be cached unless certain conditions apply.

In the first case, the conditions are that either there is a Pragma:
header (other than "Pragma: 0") or an Authorization: header (other than
"Authorization: 0") in the initial request.

In the second case, the condition is if "user name supplied with the
Basic authentication" is not empty (and, I guess, not 0). Basic
authentication uses the Authorization: header; it is not the only thing
that uses that header, and I guess that there may be a separate way to
populate that variable (but I have not investigated).

[*] strictly, it is more like "will not, not be cached". There are other
reasons why the response might not be cached.

> In addition, how can I verify the configuration is working as expected?

Watch the logs. Watch the network traffic. Watch the files on the filesystem.

Make a http request. Did it go to the fastcgi server? Was the response
cached? (Was a file in the cache recently modified?)

Repeat the http request? Did this one go to the fastcgi server, or was
it served from cache?

Did each of them do what you wanted them to do?

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login