Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
For those of you looking to properly support PURGE requests in NGINX without listening on a separate port or mucking with the uri. I saw a couple of support requests for munging the $request_uri with /purge and the like. This is problematic (as the issues suggest) so I played around with this for a bit.
Try this out:
location / {
error_page 477 = @purge;
if ($request_method = PURGE) {
return 477;
}
add_header X-Cache-Status $upstream_cache_status;
proxy_cache mycache;
proxy_cache_key "$host$request_uri"; //important!
// Skipping all implementation options
}
location @purge {
access_log /var/log/nginx/caching.purge.log;
proxy_cache_purge mycache $host$request_uri;
}
Being in a seperate location block, you can now assign ACL's without messing with the original cache details.