Cache only if no args?

Hello all,

I have a small question for you !

It is possible to cache the response from proxy_pass (that is filtered
by custom filters) only if the request has no args? If the request has
arguments, it should be served from upstream and any temporary buffer
dumped.

Example :

Request http://www.example.com/image.jpg ← cache it
Request http://www.example.com/image.jpg?lowquality=true ← don’t cache
it

All assuming that the proxy_cache_key is just the uri without params
($scheme://$http_host$uri in the specific).

So, I should have only one copy of the file in cache and should be the
“clean” one. I don’t want to cache any request that is processed by my
custom filters with different cache keys.

Thank you very much :slight_smile:

Kind regards,

Paolo Iannelli

Posted at Nginx Forum:

On Wed, Dec 01, 2010 at 03:16:36PM -0500, p.iannelli wrote:

Request http://www.example.com/image.jpg ← cache it
Request http://www.example.com/image.jpg?lowquality=true ← don’t cache
it

All assuming that the proxy_cache_key is just the uri without params
($scheme://$http_host$uri in the specific).

So, I should have only one copy of the file in cache and should be the
“clean” one. I don’t want to cache any request that is processed by my
custom filters with different cache keys.

Get nginx-0.8.53 and

proxy_cache_bypass $args;
proxy_no_cache $args;


Igor S.
http://sysoev.ru/en/

Hi Igor,

if I understood right :

proxy_cache_bypass bypass directly the cache and serve the response from
the upstream.
proxy_no_cache then prevent the response to be cached, unconditionally,
after is fetched from upstream.

Your solution, then, may fit indeed my needs, thanks ! :slight_smile:

I would like also to ask you if is possible to check whether a full
cached file is present in proxy cache and, if yes, I would like to use
my filter on that file instead of upstream. How may I check if a file is
already in cache? Can I do it in config file? If not, how should I
handle this in my module?

Thank you for you time !

Kind regards,

Paolo Iannelli

Posted at Nginx Forum: