Proxy cache for php site
Francis Daly
francis at daoine.org
Tue Nov 8 21:29:04 UTC 2011
On Tue, Nov 08, 2011 at 11:56:53AM -0500, lpugoy wrote:
Hi there,
> I'm sorry, but I don't understand the effect of cookies on proxy
> caching.
Caching involves fetching something once from the backend, and then
sending the same response to many requests.
A cookie is something that is set differently per request.
If you have one, you don't have the other.
By default.
> I'm trying to implement the same configuration as the one
> referred to, and I'm also having trouble in that it doesn't seem to be
> caching. I'm also using httperf. For every request the backend does
> return a different cookie. Is this what is preventing the caching from
> happening?
Probably.
There are (rfc) rules on caching and cacheability of a http response --
but be aware that not all of them apply to a reverse proxy like nginx.
Look at the http headers sent from your backend. If they indicate that the
response is not cacheable, nginx won't cache it -- unless you configure
it to. Setting a cookie is one way to make a response non-cacheable.
If you don't want the cookie set, don't set it.
Out-of-the-box, nginx obeys the rules. Get your backend to obey the
rules too, and it will all work fine.
If you won't do that, then you can (probably) configure nginx to break the
rules in the specific way that you want it to when proxying your backend.
For example, if the backend sets a cookie and you want nginx to cache
that, do you want it to set the same cookie for all requests; or to set
no cookie for all requests; or something else?
You're likely much better off fixing the backend.
Good luck,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list