Hello! Thanks again for the pointers. I have caching enabled, and the purpose of this is to set different expire times based on the request (if it's cacheable). So I have 3 locations: 1 for frontpage, 1 for dynamic pages and another for static content. I can't use your example though because it will ignore those headers even for requests which shouldn't be cached, hence the $skip_cache variable check. Is there a way to tie checking a variable value to the ignore headers method?
On Wed, Jan 9, 2019, 19:00 Maxim Dounin <mdou...@mdounin.ru> wrote: > Hello! > > On Tue, Jan 08, 2019 at 09:55:30AM +0200, Andrei wrote: > > > Is there a way to conditionally use proxy_ignore_headers? I'm trying to > > only ignore headers for requests which have $skip_cache = 0 for example > > If you want different proxy_ignore_headers settings for > different requests, you have to use different location{} blocks > for these requests. You can do so either by using distinct > path-based locations, or by conditionally routing some requests to > a different location (e.g., with the "rewrite" directive). > > In the particular case of requests to /abc, consider something > like this: > > location = /abc { > proxy_pass ... > proxy_cache ... > proxy_ignore_headers Expires Cache-Control; > proxy_cache_valid 5m; > } > > Note well that it makes little to no sense to only ignore Expires > and Cache-Control on cached requests, since these headers are only > used by nginx for caching. If caching is not used, these headers > are ignored anyway. See http://nginx.org/r/proxy_ignore_headers > for details. > > -- > Maxim Dounin > http://mdounin.ru/ > _______________________________________________ > nginx mailing list > nginx@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx >
_______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx