- Apply a patch to index.cgi. Actually,
at least one part of this patch is unlikely to apply for you. The idea
of the last hunk is to make the file_dir and data_dir (and the new cache_dir)
relative to a fixed location other than SCRIPT_NAME. For the rest, I don't
know how much different your version of aether might be compared to mine.
(in aether-1.7 the two chunks related to the lockfile are also rejected,
as locking is disabled in that version)
Assuming that you used the AETHER_BASE method to specify the location of the data files, you'll need to set the environment variable. Using apache: BrowserMatch .* AETHER_BASE=/var/www/emergent/index.cgi
Once you've applied this patch, you can check to see that your blog still works, and additionally that it creates files in the new -cache directory. When you strings one of them, it should look like a list of filenames that the page depends on, followed by the HTTP response.
- Build the caching program and place the
executable alongside index.cgi. You'll need to make a second environment
setting, too: BrowserMatch .*
REAL_SCRIPT=/var/www/emergent/index.cgi, which is used by cgicache to
invoke the right script in the case of a cache miss.
Now you can test the cache by going to its URL. If it serves up pages from your site, and it responds really quickly to the second query for a page, then it's working. Check that after touching a file the next page generation is slow again. It will also log some diagnostic information in the apache error.log.
- Now, either by renaming (e.g., index.cgi -> index-real.cgi, cache.cgi -> index.cgi) or by apache RewriteRules, make all your old URLs go through the cache. If nothing broke, the cache should be working.
- Two last caveats: First, if your site is available through more than
one URL, fix it now so that all other URLs redirect to a canonical URL. Second,
requests with a QUERY_STRING part are never cached, so you may also want
the code I have locally to turn certain URLs with underscores in them into
queries internally. I think this is the gist of it:
+def hack_action(name, query): + parts = name[1:].split("/") + query['action'] = parts + for p in parts[1:]: + if "=" in p: + a, b = p.split("=", 1) + query[a] = b + else: + query['__args__'] = query.get('__args__', '') + ' ' + p + return '', query @@ def perform_request(name, query): if name[:1] == u'/': # should always be true. name = name[1:] + if name.startswith("_"): + name, query = hack_action(name, query) + correct_name = correct_case(name)Now, you can use a URL like http://emergent.unpythonic.net/_atom/hasname=1/name= instead of http://emergent.unpythonic.net?action=atom&hasname=1&name=, making your RSS feed benefit from caching as well. You can redirect users of the legacy URL to the cached URL too:
RewriteRule ^/\?action=atom\;hasname=1\;name=$ /_atom [R,L] RewriteRule ^/\?action=atom\&hasname=1\&name=$ /_atom [R,L]
Files currently attached to this page:
Entry first conceived on 13 September 2011, 12:53 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2012 Jeff Epler