How to cache image urls with query strings?

Francis Daly francis at
Sat Mar 4 12:03:09 UTC 2017

On Fri, Feb 24, 2017 at 07:33:19AM -0500, 0liver wrote:

Hi there,

> Can anybody point to me to the necessary pieces of information to get
> caching for resources with query strings to work?

There should be nothing special needed on the nginx side for this to
work -- it caches what it is told to cache by configuration and response
from upstream.

Since the only change you made to the requests is the query string, the
most likely thing is that the upstream server sends different response
headers for requests with and without query-strings.

Possibly the response from upstream now has a "do not cache this"

Can you compare the http responses from the upstream server for the old
and new cases?

If it does say "do not cache", then you can either configure it not to
say that; or configure nginx not to agree to that part of the response,
as was shown in an earlier reply.

If it does not, then more investigation is needed.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list