Welcome! Log In Create A New Profile

Advanced

Re: How to cache image urls with query strings?

February 26, 2017 05:12AM
Hi,

The proxy_cache_key uses request parameters by default. As stated in http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_key it uses $scheme$proxy_host$request_uri by default.

The $request_uti do contain the request parameters: http://nginx.org/en/docs/http/ngx_http_core_module.html#var_request_uri

$request_uri
full original request URI (with arguments)

So a way to deal with this is using a self-made cache_key and strip the arguments with a regex:

set $cacheuri $request_uri;
if ($cacheuri ~ /example/images/([^\?]*)) {
set $cacheuri /example/images/$1;
}
proxy_cache_key $cacheuri;

Note: the regex is untested, but just to give you an idea.

JP
Subject Author Posted

How to cache image urls with query strings?

0liver February 24, 2017 07:33AM

Re: How to cache image urls with query strings?

Nelson Marcos February 24, 2017 08:52AM

Re: How to cache image urls with query strings?

0liver February 24, 2017 09:23AM

Re: How to cache image urls with query strings?

jeanpaul February 26, 2017 05:12AM

Re: How to cache image urls with query strings?

dewanggaba February 24, 2017 09:44AM

Re: How to cache image urls with query strings?

Francis Daly March 04, 2017 07:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 53
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready