Short description

Moin should return Last-Modified headers, so that http proxies and caches can cache content and advanced setups can do performance improvements using for example mod_cache or squid. From #moin:

The discussion below is wrong! Most browsers use, in presence of last-modified, a heuristic described at end of rfc2616 13.2.4: http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2.4. Mozilla uses this heuristic according to http://www.mozilla.org/projects/netlib/http/http-caching-faq.html

[11:44] LeoSimons: Hi gang! over at wiki.apache.org, we've been having some performance issues ever since upgrading to moin 1.3 and at the same time migrating from a FreeBSD machine to RHEL (so we're not sure which of the two made the difference). Regardless, we've been looking into using mod_cache to reduce the load. Some details are at http://issues.apache.org/jira/browse/INFRA-360, including a patch for more conservatie Cache-Control headers (that's probably a little redundant) that also sets Last-Modified headers.
[11:44] LeoSimons: I would suggest someone takes a look at our patch, fixes it (its no doubt not the best way to do things) and integrates this into moin proper. It should help a lot with load reduction, esp. for people using proxies.
[11:45] LeoSimons: (setting Last-Modified allows content negotiation via If-Modified-Since)
[11:46] xorAxAx: LeoSimons: on which moinmoin version are you currently?
[11:46] xorAxAx: LeoSimons: am i right at this point - the patch will just help if you use a reverse caching proxy
[11:46] LeoSimons: 1.3.4 (or 1.3.3, eh...)
[11:48] LeoSimons: xorAxAx: setting a Last-Modifed allows all kinds of caching strategies to happen between your server and user X. In our case the caching is always going to happen within apache itself (using mod_cache), which is a kind-of reverse caching proxy, but other setups are not unthinkable.
[11:49] xorAxAx: LeoSimons: but the straight use of a browser wont be sped up by this patch
[11:49] xorAxAx: LeoSimons: would it?
[11:49] LeoSimons: xorAxAx: correct.
[11:49] xorAxAx: we would need to send not-modified
[11:49] xorAxAx: but its worth to consider merging, thanks
[11:50] xorAxAx: i dont like the opt-out thing, though
[11:50] LeoSimons: xorAxAx: actually, what would need to be done would be a shortcut through the moin code that supports HEAD requests
[11:50] xorAxAx: yeah
[11:50] LeoSimons: content-negotiation sometimes fetches headers to determine whether it should fetch a body. Rendering the body is expensive for wikis.
[11:51] xorAxAx: maybe make an official feature request on the wiki

The user problem

Each moin response contain user-dependent items:

Requesting the same unchanged page by different users require that moin will handle all requests. Moin itself caches page content, rendering page content takes about 1/10 of the time of a typical request.

For improving at the http level, Last-Modified header would be far too simple (see above). Maybe we could use an Etag header made out of the key values influencing the content. -- ThomasWaldmann 2005-06-05 15:28:02

+1 to using an ETag, along with Cache-Control: max-age. See: cgi_buffer for example code, and more information about caching. -- MarkNottingham

Patch

Compare patch to support mod_proxy.

The patch looks correct but creating the last modified header should not be done in Page.py. It should be probably in request. Also, maybe all the logic can be in one function:

def canUseHTTPCaching(self, action):
    return not self.user.valid and action in <list of cacheable actions> and <other logic>   

Then another function to set the last modified header.


CategoryFeaturePatched

MoinMoin: FeatureRequests/LastModifiedHeader (last edited 2009-09-30 16:44:36 by ThomasWaldmann)