Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the option to purge cache files directly without ngx_cache_purge #78

Merged
merged 1 commit into from Apr 19, 2015

Conversation

bcole808
Copy link

The issue

I needed to be able to purge cache files without using the ngx_cache_purge module.

Solution

This pull request adds an option to the "Purge Options" area to allow the site admin to choose how cache files should be purged. The default option is to use a GET request to the /purge version of the URL, as required by ngx_cache_purge. The second option lets the plugin directly remove the cache files from the server.

Screenshot of new option:

screen shot 2015-04-17 at 4 07 04 pm

How it works

I followed information from this article to compute the correct cache file to delete. The URL to delete is hashed with md5 and then given a specific folder and file name based on that hash.

Caveats

In order for the "delete local files" option to work, the following must all be true:

  • Cache is stored on the same server and * RT_WP_NGINX_HELPER_CACHE_PATH* is defined.
  • Default nginx cache level must be used; levels=1:2
  • Cache key must be: fastcgi_cache_key "$scheme$request_method$host$request_uri"

Testing

So far it seems to work on my staging server tests. If someone else can help double check that everything is working great that would be much appreciated.

@bcole808 bcole808 changed the title Added the option to purge cache files directly from disk Added the option to purge cache files directly without ngx_cache_purge Apr 17, 2015
rahul286 added a commit that referenced this pull request Apr 19, 2015
Added the option to purge cache files directly without ngx_cache_purge
@rahul286 rahul286 merged commit a776dcd into rtCamp:master Apr 19, 2015
@rahul286
Copy link
Member

Thanks for amazing PR, both in terms of functionality and documentation. :-)

@ghost
Copy link

ghost commented Apr 21, 2015

Very nice indeed, thanks!

@cromulus
Copy link

cromulus commented May 1, 2015

Just a note: could we allow RT_WP_NGINX_HELPER_CACHE_PATH to be defined in the user interface? Or print it's current value?

I love this PR! Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants