AJAX Cache Purge Cookie Plugin

This plugin sets a “version” cookie of your site’s content, which can be used for time-based cache invalidation, as the cookie is checked and updated (if necessary) on each page request through a single AJAX request.

Download: ajax-cache-purge.zip (June 26, 2010)


Please note that this plugin is intended for people who run their own servers.

  1. Upload and enable the plugin.
  2. Add the value of wp_cache_key_cookie to the cache key.

Nginx Example

fastcgi_cache_path 	/var/www/cache  levels=1:2
			inactive=2m max_size=2000m;

fastcgi_temp_path 	/var/www/cache/tmp;

server {
	# other config options

	location ~ \.php$ {
		# wp_cache_key_cookie is supplied by the plugin
		set $wp_cache_key $scheme$host$request_uri|$cookie_wp_cache_key_cookie;

		#add key in header for debugging
		#add_header	WP_KEY $wp_cache_key;

		fastcgi_cache 		wp-cache;
		fastcgi_cache_key 	$wp_cache_key;


  1. TJ says:

    Is jQuery required in the theme header for this to work properly? I noticed the jQuery.post bit in the footer but wasn’t sure if this was required.

    • Kaspars says:

      Yes, TJ, jQuery is required. You should take a look at the related posts of this article to better understand the underlying idea of this plugin.

  2. TJ says:

    Thanks! You should really consider open-sourcing this on GitHub at least. Out of all of the caching implementations of WordPress and Nginx I’ve seen, this is the most efficient and cleanest I’ve seen.

    Great work.

Leave a Reply