TLDR;
How to flush mod_pagespeed cache in LiquidWeb‘s new Managed WordPress package:
SSH as root and touch a file:
ssh root@###.###.###.### touch /var/cache/pagespeed/cache.flush
The mod time of this file is used by mod_pagespeed to determine if its cache needs to be flushed.
Setup
I’ve recently had the opportunity to try out LiquidWeb’s new Managed WordPress package. The initial setup was fast, and simple with a number of really awesome performance settings, such as HHVM, Memcached and PageSpeed setup out of the box.
So the site has been deployed and is noticeably faster. The only issue was finding a way to flush the mod_pagespeed cache.
According to the PageSpeed docs, the most basic method is to
simply touch the file “cache.flush” in the directory specified by `FileCachePath`
My process for finding / doing this followed:
- Determine where `FileCachePath` was on the server
- Flush the cache
Finding FileCachePath
This server was a CentOS one, but this should be similar for other systems. First off, we need to login as root and find the apache configuration:
ssh root@###.###.###.### ps -ef | grep apache # gives us: root 23433 1 0 Jan14 ? 00:00:04 /usr/local/apache/bin/httpd -k start nobody 24069 23433 0 12:04 ? 00:00:00 /usr/local/apache/bin/httpd -k start nobody 24070 23433 0 12:04 ? 00:00:12 /usr/local/apache/bin/httpd -k start nobody 24071 23433 0 12:04 ? 00:00:10 /usr/local/apache/bin/httpd -k start nobody 24072 23433 0 12:04 ? 00:00:09 /usr/local/apache/bin/httpd -k start nobody 24240 23433 0 12:04 ? 00:00:18 /usr/local/apache/bin/httpd -k start root 30015 29909 0 13:50 pts/0 00:00:00 grep --color=auto apache
This gives us to the location of the currently running apache process. Next is to use the above path to find the location of the apache configuration file. For me, the apache path was /usr/local/apache/bin/httpd
.
/usr/local/apache/bin/httpd -V | grep SERVER_CONFIG_FILE # gives us: -D SERVER_CONFIG_FILE="conf/httpd.conf"
In some systems, that’s the full path, but for me it was a relative path, so I needed to find the apache root:
/usr/local/apache/bin/httpd -V | grep HTTPD_ROOT # gives us: -D HTTPD_ROOT="/usr/local/apache"
Opening that file I found that the actual pagespeed configuration was included in an additional sibling file called pagespeed.conf
.
less /usr/local/apache/conf/httpd.conf # determine that I need to look in 'pagespeed.conf' less /usr/local/apache/conf/pagespeed.conf
Being new to PageSpeed, this file was an interesting look into the various options available, however for my purposes, this line was exactly what I needed:
ModPagespeedFileCachePath "/var/cache/pagespeed/"
Flush the Cache
So now we have what we need to flush the cache — simply create a file whose mod time is used by PageSpeed to determine when to flush the cache!
touch /var/cache/pagespeed/cache.flush