---
title: AJAX Cache Purge Cookie Plugin
date: 2010-06-26T01:24:12+00:00
modified: 2012-05-19T16:40:37+00:00
permalink: https://kaspars.net/blog/ajax-cache-purge-cookie-plugin
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
post_tag:
  - Nginx
  - Plugin
category:
  - Web Performance
  - WordPress
---

# 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](https://kaspars.net/wp-content/uploads/2010/06/ajax-cache-purge.zip) (June 26, 2010)

### Installation

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
			keys_zone=wp-cache:10m
			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;
	}
}
```