selective, manual file caching


I've disabled WP-Super-Cache on UCalgaryBlogs.ca because it was doing quirky things like showing the anonymous front page after someone logged in, etc... And, with our low load and mostly logged in users, it really wasn't necessary.

Except for the RSS feeds used to generate the Recent Posts and Recent Comments sections on the front page of the site. Without WP-Super-Cache enabled, the front page (and ONLY the front page) took glacial epochs to load, as the RSS feeds were generated, parsed, and embedded. I wanted to be able to cache the feeds, without having to throw the switch on caching the entire site.

Then it hit me - it's trivial to set up a cron job to curl the feeds to static files periodically, and then I could just use those static files to generate the Recent blocks on the front page. Duh...

So, I modified the crontab on the server to add these two lines:


*/15 * * * * /usr/bin/curl "http://ucalgaryblogs.ca/wpmu-feed/" > /home/commons/webdata/ucalgaryblogs.ca/postsfeed.xml
*/15 * * * * /usr/bin/curl "http://ucalgaryblogs.ca/wpmu-feed/comments/" > /home/commons/webdata/ucalgaryblogs.ca/commentsfeed.xml

So, every 15 minutes, the sitewide Recent Posts and Recent Comments feeds are updated. I use the static files to generate the display on the front page, using the web-visible URLs for the files at http://ucalgaryblogs.ca/postsfeed.xml and http://ucalgaryblogs.ca/commentsfeed.xml respectively.

Sometimes, it's easier to just pull out another tool from the server toolbox, rather than trying to find a way to do it within WordPress all the time...


work 

See Also

comments powered by Disqus