Ticket #2114 (new defect)

Opened 9 years ago

Last modified 7 years ago

Respect HTTP standards for stylesheets and the like

Reported by: gracinet Owned by: madarche
Priority: P1 Milestone: CPS 3.5.6
Component: CPS (global) Version: TRUNK
Severity: major Keywords: HTTP cache


Since ages, the practice for CPSDefault's stylesheets and javascript has been to put an explicit Last-Modified to the current time minus 2 weeks and an expiration to the current time plus one day.

The purpose is obviously to let the user and intermediate agents serve from cache almost immediately after a modification, but this is overall conter-productive in the long run. If I understand the spirit of RFC 2616 correctly, what the originating server provides with these headers is useful information, not directives (Cache-Control is made for that). This policy is just asking for trouble and users complaining about the content being stale in the case of publication-oriented sites. Furthermore, a HEAD request provides different values for these headers (closer to reality). One cannot predict the results of such inconsistencies in terms of content correctness and/or search engine correctness.

Therefore, it's infinitely better to provide the correct information rather than cheat on it. For instance, Apache's mod_cache would actually check on a regular basis but not that often on the actual content, because it implements the heuristical algorithm explained in the RFC, and manage 304 responses and the like in the meanwhile (which DTML methods can't do).

The default behaviour of a DTML method is not to set any of these headers, but its last modification date is available from itself like this:

<dtml-let last_modified="REQUEST['PUBLISHED'].bobobase_modification_time().toZone('GMT')" >

Most of the DTML methods to correct are in CPSDefault, but virtually any CPS component including terminal UIs is to be corrected. Not even to mention overrides in custom projects. Better late than never.

Change History

comment:1 Changed 9 years ago by gracinet

  • Milestone changed from CPS 3.5.0 to CPS 3.5.1

Corrected wrong milestone

comment:2 Changed 9 years ago by gracinet

  • Milestone changed from CPS 3.5.1 to CPS 3.5.2

There's a complication : the above retrieval of last_modified has been done for a customised version of default.css, ie, a persistent DTMLMethod. But it doesn't work for FSDTMLMethod (un-customized version, directly from the skins layer). Namely, the bobobase_modification_time defaults to current time, which is very bad.

We need to cook a uniform call that'd apply for both. No time for this right now: postponing.

comment:3 Changed 8 years ago by gracinet

  • Milestone changed from CPS 3.5.3 to CPS 3.5.4


comment:4 Changed 7 years ago by gracinet

For all classes deriving from FSObject (including of course FSDTMLMethod), there's an attribute for that: _file_mod_time. It default to 0 if there was a problem performing stat on the file itself.

We should create a function in CPSUtil.http for that. NB: in CPS >= 3.6, these global stylesheets will be less and less used. The situation is a bit different for other static resources, notably javascript.

comment:5 Changed 7 years ago by gracinet

  • Priority changed from P2 to P1
  • Milestone changed from CPS 3.5.5 to CPS 3.5.6


Note: See TracTickets for help on using tickets.