Personal tools
You are here: Home Products CacheFu Documentation How-Tu Expiring Content
Document Actions

Expiring Content

Warning: This item is marked as outdated.

This How-to applies to: 0.1

Using CMFSquidTool to proactively expire cached content views when the underyling object is modified in zodb.

Crash-Fu

If you haven't read Crash-Fu, you should start there before using any lone products from CacheFu or older CMFSquidTool release unless well informed.

CMFSquidTool

Useful snippets from Geoffd's README.txt

CMFSquidTool hooks the reindex method on content objects. When an object changes, CMFSquidTool purges views of the content from Squid to make sure Squid is not holding on to stale content.

And:

When an object changes, CMFSquidTool will purge old views of the object from Squid's cache. The object's ETag will change, too, so PageCacheManager will no longer serve the old, cached version, and CMF will no longer respond to conditional GETs for the old object with a 304.

Also quite important:

CacheFu contains a patched version of CMFSquidTool (don't use the one from Enfold).

Installing and Configuring CMFSquidTool

Install CMFSquidTool from the CacheFu distribution (it contains several useful patches that the Enfold version does not yet have). It will create a tool called portal_squid in the ZMI. This is where you configure CMFSquidTool.

For Cache type, select Squid.

If you have Squid directly responding to requests:

  • For Portal URLs for the cache, enter http://your.domain.name.here. If it is possible to access your site through multiple URLs (e.g. http://www.mysite.com, http://mysite.com, https://www.mysite.com), enter all of those URLs.
  • For URLs to purge, enter:
      python:object.getUrlsToPurge(setup='squid_direct')
    

If you have Squid behind Apache:

  • For Portal URLs for the cache, enter the direct url of your squid host, http://127.0.0.1:3128 if you are following CacheFu example verbatim on a single machine.
  • For URLs to purge, enter:
       python:object.getUrlsToPurge(setup='squid_behind_apache')
    

Customize the script getSiteUrls.py in CacheSetup/skins/cache_setup so that it returns your site's URLs.

[ed: make sure to install CacheSetup ;d]

Testing CMFSquidTool

Visit a document that is cached by Squid as an anonymous user. Make sure you get an X-Cache: HIT header in response (you may need to make a second visit).

If you have Squid responding directly to requests:

  • Enter the URL you just visited relative to the portal root in the "Purge URL" box and click Go!. For example, for http://mysite.com/foo/bar, enter "foo/bar".

If you have Squid behind apache:

  • Enter the prefix http/your.site.url/ followed by URL you just visited relative to the portal root in the Purge URL box and click Go!. For example, for http://mysite.com/foo/bar, enter http/mysite.com/foo/bar.

You should see 200 http://someurlhere on the next page. The 200 means that CMFSquidTool successfully purged the content. If you get a 404, something is wrong (you already purged the page from cache, the page was not in cache or you do not have permission to purge pages on cache).

More to come...

[ed: note this is all transcribed and not 100% working on my site yet]

by Justin Ryan last modified May 7, 2006 - 22:58
Contributors: geoffd

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by