Welcome! Log In Create A New Profile

Advanced

Re: ignore part of URL to force caching?

October 05, 2012 06:10AM
On Thu, Oct 04, 2012 at 02:20:30PM -0400, AJ Weber 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'm not explaining myself properly, please let me know and I'll try
> another route. :)

You can use "proxy_cache_key":
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_key

For example, to completly ignore query strings:

location /swf/ {
...
proxy_cache ...
proxy_cache_valid 5m;
proxy_cache_key $proxy_host$uri;
}

or to account query strings parameters ONE and TWO:

location /swf/ {
...
proxy_cache ...
proxy_cache_valid 5m;
proxy_cache_key $proxy_host$uri?$arg_ONE&$arg_TWO;
}


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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

ignore part of URL to force caching?

aweber October 04, 2012 02:22PM

Re: ignore part of URL to force caching?

António P. P. Almeida October 05, 2012 05:50AM

Re: ignore part of URL to force caching?

Igor Sysoev October 05, 2012 06:10AM

Re: ignore part of URL to force caching?

António P. P. Almeida October 05, 2012 06:22AM

Re: ignore part of URL to force caching?

Igor Sysoev October 05, 2012 06:10AM

Re: ignore part of URL to force caching?

aweber October 05, 2012 11:46AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 179
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready