Welcome! Log In Create A New Profile

Advanced

FastCGI Cache /purge/ resulting in 404 and no catch purging

Posted by bluedrank 
FastCGI Cache /purge/ resulting in 404 and no catch purging
October 26, 2015 11:49PM
I'm encountering an issue with my server being unable to purge content using the nginx helper plugin. I'm using the code below, which shou;ld purge correctly using the nginx purge module, but whenever /purge/ is called it results in a 404.

I'm using:
Nginx 1.9.5
HHVM (latest)
WordPress

I've verified the cache's hit, miss, bypass, expired status in the header and in the directory itself. Caching works without issue. The problem happens when I try to purge. So what nginx helper does is conditional purging when you make a post. It does this by adding /purge/ to the address. So purging mydomain.com/test-post would be mydomain.com/purge/test-post. When I do an action to trigger the conditional purging, it fails to remove the contents of /var/run/nginx-cache. In additional, manually surfing to mydomain.com/purge/test-post results in an nginx 404 error, which is different than what would happen if I visited a regular non-existent page on the site. So if I visited mydomain.com/this-page-doesnt-exist, WordPress would handle the error internally and tell me "Oops! That page can’t be found". So clearly the /purge rewrite is doing something, but it's just resulting in 404 every time. Why it's doing this is a total mystery to me.

Here are the relevant contents of my .conf files, with the non-important stuff removed.
#inside nginx.conf
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=FCGICACHE:500m inactive=60m;
fastcgi_cache_key $scheme$request_method$host$request_uri;
fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 90;
fastcgi_read_timeout 90;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_max_temp_file_size 5m;
fastcgi_pass_header Set-Cookie;
fastcgi_pass_header Cookie;



Below is located inside my hvvm.conf file, which is called from mydomain.com.conf.

# inside hhvm.conf
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache FCGICACHE;
fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1h;
fastcgi_cache_valid any 1h;
fastcgi_cache_min_uses 2;
add_header X-FastCGI-Cached $upstream_cache_status;

location ~ /purge(/.*) {
fastcgi_cache_purge FCGICACHE $scheme$request_method$host$request_uri;
}
Re: FastCGI Cache /purge/ resulting in 404 and no catch purging
October 27, 2015 12:25AM
I'm unable to edit my original post, but the contents of the bottom .conf file had a missing } that I accidentally removed while formatting this post. It should read:

# inside hhvm.conf
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache FCGICACHE;
fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1h;
fastcgi_cache_valid any 1h;
fastcgi_cache_min_uses 2;
add_header X-FastCGI-Cached $upstream_cache_status;
}

location ~ /purge(/.*) {
fastcgi_cache_purge FCGICACHE $scheme$request_method$host$request_uri;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 87
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