ignore part of URL to force caching?

Igor Sysoev igor at sysoev.ru
Fri Oct 5 10:09:08 UTC 2012


On Fri, Oct 05, 2012 at 11:49:12AM +0200, António P. P. Almeida wrote:
> On 4 Out 2012 20h20 CEST, aweber at comcast.net wrote:
> 
> > I would like to "override" the intent of the app server that is
> > basically disabling any caching of the backend file.  For example,
> > they are embedding a "noCache=#######" parameter at the end of the
> > URL (there are other parameters following, but if I can check the
> > url up-to the "?"  that would suit me fine).
> >
> > This is actually a dynamically generated SWF file, but the file is
> > then constant for a reasonable amount of time such that I'd like to
> > cache it for a few minutes.
> 
> > Is there a way in a specific "location" to tell nginx to ignore the
> > parameters (or any portion of the URL) when determining the cached
> > object for that URL?  In other words, tell nginx to cache content
> > for that location, say only 5min, and ignore all parameters when
> > determining whether to cache and how to match cached content?
> 
> If I understand correctly. Inside your main cached location you can do:
> 
> if ($request_uri ~* noCache) {
>    return 418;
> }
> 
> error_page 418 =200 @other-cached-location;
> 
> And add @other-cached-location:
> 
> location @other-cached-location {
>     # Set your cache parameters here and serve the content.
> }

There is proxy_cache_key for this.


-- 
Igor Sysoev
http://nginx.com/support.html



More information about the nginx mailing list