nginx-modules / ngx_cache_purge

nginx module which support to purge ngx_http_(fastcgi|proxy|scgi|uwsgi)_module cache backend
Other
209 stars 34 forks source link

Module doesn't support purging encoded urls #21

Closed momkin closed 5 years ago

momkin commented 5 years ago

Hello , When i try to purge arabic url i from the cache i get error 412 Precondition Failed nginx

but if i try to purge the homepage or english URL it works fine !

denji commented 5 years ago

Hello, Can you show a arabic HTTP request header and the URL?

momkin commented 5 years ago

Hi , I will explain the problem , when a page get cached from nginx fastcgi the key name become like this

KEY: httpGETwww.mywebsite.com/episodes/%D9%85%D8%B3%D9%84%D8%B3%D9%84-taboo-%D8%A7%D9%84%D9%85%D9%88%D8%B3%D9%85-%D8%A7%D9%84%D8%A7%D9%88%D9%84-%D8%A7%D9%84%D8%AD%D9%84%D9%82%D8%A9-1

And when i request

www.mywebsite.com/purge/episodes/%D9%85%D8%B3%D9%84%D8%B3%D9%84-taboo-%D8%A7%D9%84%D9%85%D9%88%D8%B3%D9%85-%D8%A7%D9%84%D8%A7%D9%88%D9%84-%D8%A7%D9%84%D8%AD%D9%84%D9%82%D8%A9-1

I get error : 412 Precondition Failed nginx

this is because the url is not recognized as utf8 , the url is in arabic language that's why the purge doesn't works , however the purge is working just fine with english URL's

I have tried to set charset utf8 on nginx.conf and i also disabled gzip but it didn't help !

momkin commented 5 years ago
proxy_cache_key $request_uri;

i don't use proxy its nginx + fascgi cache only !

denji commented 5 years ago
fastcgi_cache_key $uri$is_args$args; # /purge/episodes/مسلسل-taboo-الموسم-الاول-الحلقة-1
fastcgi_cache_key $request_uri; # /purge/episodes/%D9%85%D8%B3%D9%84%D8%B3%D9%84-taboo-%D8%A7%D9%84%D9%85%D9%88%D8%B3%D9%85-%D8%A7%D9%84%D8%A7%D9%88%D9%84-%D8%A7%D9%84%D8%AD%D9%84%D9%82%D8%A9-1

The downside of $request_uri is the lack of URI normalization ($uri).

momkin commented 5 years ago

I did that fastcgi_cache_key "$scheme$request_method$host$uri$is_args$args$geoip2_data_country_code$mobile_request";

Now all the cached key files has the some URL KEY: httpGETmywebsite.com/index.phpSAmobileversion