0

We are currently using proxy_cache_bypass directive on NGINX to bypass caching when a cookie is set. This is our code:

proxy_cache_bypass $cookie_user;

However, we only want the server to bypass the cache for HTML content. We still want cached images to be served from the cache, even when the cookie is set.

Can this be achieved? I've looked everywhere and can't find an example.

Your help is always appreciated.

Many thanks.

3
  • Why do you proxy images instead of serving them directly by nginx?
    – Alexey Ten
    Jul 3, 2015 at 15:39
  • The origin server and NGINX proxy are sitting on two different (physical) servers. Doing it this way works for us as we have a long cache expiration time on the images. Can what I mention in my original question be achieved? Thanks for your help. Jul 4, 2015 at 9:29
  • You could use separate location for images and html. At the time nginx decides should it use cache on not, it has only request from client and has no idea what content type of response would be.
    – Alexey Ten
    Jul 4, 2015 at 13:38

0

You must log in to answer this question.

Browse other questions tagged .