Flushing PageSpeed Server-Side Cache
By default, the system is configured to support only whole-cache flushes - we'll call this legacy mode. As of PageSpeed version 184.108.40.206, it can be configured to also allow purging of individual URLs. The two modes operate differently and you may choose between them for each virtual host. Legacy mode is on by default, to provide compatibility with existing scripts and other infrastructure that might have been built around it.
In a future release, individual URL purging will become the default. Subsequent to that, the legacy whole-cache flushing mode will be eliminated.
You can choose between the two modes with the
EnableCachePurge argument. If set to "on" you will get the new behavior, with individual URL purging, while "off" will give you the legacy behavior. The default is "off", as if your configuration read:
pagespeed EnableCachePurge off
Cache.flush (Legacy mode)
In this mode, simply touch the file
cache.flush in the directory specified as
FileCachePath. If the
cache.flush doesn't exist you can simply create an empty file.
sudo touch /cache/pagespeed/cache.flush
echo "" > c:\pagespeedcache\cache.flush
The system may take up to 5 seconds to take effect (changeable via option
CacheFlushPollIntervalSec described below).
Individual cache purging
Note: New feature as of 220.127.116.11
In this mode, the cache may be purged by sending HTTP requests to the server, using a configurable path. The cache can be purged via an HTTP GET, PURGE, or DELETE, once a handler has been configured. The admin site makes this easier by providing a graphical interface to initiate purge requests and see what entries have been purged.
To enable individual URL cache purging, you must configure the admin site, specify a PurgeMethod, or both. Plus you must turn on EnableCachePurge:
pagespeed EnableCachePurge on pagespeed PurgeMethod PURGE (optional)
This establishes three methods to purge the cache of a URL, or to purge the entire cache, assuming PageSpeed is running on example.com:
|Method||Purge single URL||Purge entire cache|
|Admin GUI||Admin interface|
The Purge requests for individual URLs made via the GUI are executed via an HTTP GET. In either case, the URL being purged is specified relative to the ORIGIN of the admin site. In these examples,
path/file.ext is combined with
example.com to purge the path
http://example.com/path/file.ext from the cache.
When the new mode of cache purging is enabled, the purges take place immediately, there is no five second delay. Note that it is possible to purge the entire cache, or to purge one URL at a time. It is not possible to purge by regular expression or wildcard. The URL purging system works by remembering which URLs are purged and validating each URL coming out of cache against them. There is a limitation to the number of distinct URLs that can be purged. When that limit is exceeded, everything in the cache older than the oldest remaining purge request will be dropped. The limitation is high enough that it's not expected to be exceeded often, but is not currently changeable.
The following limitations apply to both method the legacy and new methods of cache purging.
Caution: In a multi-server system, you must run these commands on every server. All the cache data from VirtualHosts using that cache directory will be flushed. This is true even when using memcached: the cache flush information is kept locally on each machine running PageSpeed, not in the cache itself. This is because of the L1 caches that run locally on each machine, and because memcached does not guarantee persistance.
Caution: Flushing or purging the cache does not delete the old files from the directory, the memcached server, or PageSpeed's in-memory cache, but it tells PageSpeed to ignore those files.
Note: After flushing or purging the cache, the stale files will eventually be replaced with fresh copies or removed by the normal file cache cleaning process (see
You can change the polling interval and name of the cache-flush file in the configuration file. If you set the polling interval to 0, the cache flushing feature will be disabled. If you specify the cache flush filename as a relative path, PageSpeed will look for that file in the
FileCachePath directory. If you use an absolute path, then the caches associated with multiple virtual hosts can be flushed all at once.
Cache Flushing and Purging Options
pagespeed CacheFlushFilename alternate_filename pagespeed CacheFlushPollIntervalSec number_of_seconds