This is solved by using a different url_prefix_static for every release. Moin does this by default since quite a while (1.6?).
We need some method to auto update some stuff like:
- Javascript files used by moin (as soon as we stop feeding js embedded in page src)
- Icons and CSS maybe too
I am trying to find a solve that.
That way can't simply be some expiry, because that does not solve the problem, it just makes the problem period shorter (but makes higher traffic and lower speed).
Currently investigating about 304 and etag.
Maybe we need to feed those files via CGI?
Random bits i found on the internet
http://www.oddmuse.org/cgi-bin/wiki/Caching
From http://annevankesteren.nl/2005/05/http-304
function http_modified($last_modified,$identifier){ $etag = '"'.md5($last_modified.$identifier).'"'; $client_etag = $_SERVER['HTTP_IF_NONE_MATCH'] ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false; $client_last_modified = $_SERVER['HTTP_IF_MODIFIED_SINCE'] ? trim($_SERVER['HTTP_IF_MODIFIED_SINCE']) : 0; $client_last_modified_timestamp = strtotime($client_last_modified); $last_modified_timestamp = strtotime($last_modified); if(($client_last_modified && $client_etag) ? (($client_last_modified_timestamp == $last_modified_timestamp) && ($client_etag == $etag)) : (($client_last_modified_timestamp == $last_modified_timestamp) || ($client_etag == $etag))){ header('Not Modified',true,304); exit(); }else{ header('Last-Modified:'.$last_modified); header('ETag:'.$etag); } }
http://www.cmlenz.net/blog/2005/05/on_http_lastmod.html describes how we can avoid caching problems with changing user login state, user prefs, etc.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
http://www.mnot.net/cacheability/ http://www.mnot.net/cache_docs/
http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers
Plan for MoinMoin
- for the "static" stuff, we need to
- send a quite short "Expires:" http header, forcing browser to re-validate content often
- we also need to send a Last-Modified http header
- apache obviously does send a Last-Modified header
- do we also need that Etag header?
- apache sends an auto-generated Etag header
- for successful and low cost revalidation, we need to:
- support 304 http response
apache
- HEAD
apache
- support 304 http response
Apache 2.0
Load mod_expires and configure it like this:
ExpiresActive On ExpiresDefault "now plus 3600 seconds" ExpiresByType text/html "now plus 1 seconds" ExpiresByType application/x-javascript "now plus 120 seconds" ExpiresByType image/png "now plus 120 seconds" ExpiresByType image/gif "now plus 120 seconds"
This should be in effect for serving the files from url_prefix (/wiki) directory.
Remark: the extremely short expiry for text/html is needed for editing pages or it might show the old content from the cache after saving. Especially IE is affected, Mozilla/FF seems to work ok nevertheless.
Intranet: you maybe don't have to worry about traffic and load, so keep those expires values quite low. This will lead to many GET (304) requests (when the browser are checking whether their cached content is still uptodate), but your browsers will all show uptodate content and use uptodate code. If something is not uptodate, 120 seconds later it will be.
Internet: you will have to find a sane compromise between traffic and user's browsers working with old / incorrect JS code for the expires interval.