On Wed, Apr 28, 2010 at 12:35 PM, Vidar Ramdal <[email protected]> wrote: > On Wed, Apr 28, 2010 at 1:13 PM, Felix Meschberger > <[email protected]> wrote: >> Hi all, >> >> I have been resonating with a collegue about a request level Filter >> for Sling to support caching. >> >> The idea (and partly implemented by a prototype) is to have the >> request filter setup default caching behaviour of the response (if the >> response is cacheable at, that is the request method must be GET and >> there are no request parameters): >> >> * The Cache-Control header is preset with values from configuration >> matching the request URI (or resource path) >> * The Last-Modified header is preset with the jcr:lastModified >> property of the requet's resource >> * Eager responding with 304/NOT MODIFIED if the If-Modified-Since >> header is set and a last modification time of the resource can be >> resolved. > > The question is how useful such a filter would be if only the > last-modified date of the requested resource is used.
That *is* in fact a valid concern, which my proposal does not account for yet. I think this also aligns with what Bertrand has in mind with extensibility of the basic mechanism. > > In our application at least, there is a large number of resources > involved when serving a request. Most CMSs list out menus, for > example, where the menu items are other resources. If one of those > resources have changed, or if there has been a new menu item created, > it means the menu will be out of date if the requested resource itself > is unmodified. > > To solve this, we could introduce a resource tracker, which tracks > which resources are being invoked on a request. The latest > last-modified date of these resources will then be matched with the > requests If-Modified-Since header. If you have to actually run all scripts to check the If-Modified-Since header before actually processing the request, this would effectively double the request processing time. I would say in this case it would probably be better to switch of eager If-Modified-Since check and just process the request (albeit with Cache-Control and Last-Modified preset). Regards Felix > > -- > Vidar S. Ramdal <[email protected]> - http://www.idium.no > Sommerrogata 13-15, N-0255 Oslo, Norway > + 47 22 00 84 00 / +47 21 531941, ext 2070 >
