On 27.11.2007, at 20:38, Jonas Borgström wrote:
> Emmanuel Blot wrote:
>>> Has there been thought given to adding Expires headers to our  
>>> images and css
>>> files in order to reduce load times of Trac installs?
>>
>> To reduce load times, it is probably more effective to let Apache (or
>> whichever HTTP server) serve the static files (images, css,
>> javascript) using the htdocs parameter in trac.ini. That said, for
>> tracd-only installation an expires header might help.
>
> One important thing to remember when using Expires-headers with dates
> far in the future is that there's no good way to force users to re-
> download cached css/js/png files. One way to get around that is to  
> serve
> all static files with lighttpd and remembering to change  
> htdocs_location
> in trac.ini to a new location every time Trac is upgraded or some file
> has been modified. For example like this:
>
> [trac]
> htdocs_location = http://static.edgewall.org/YYYY-MM-DD/
>
> Where YY-MM-DD is updated every time some file is modified.

The other possible approach to this is to add a dummy query string  
parameter to all static resource URLs, which IIRC is what Rails does.

I.e. when you construct the URL to a static resource, you stat the  
corresponding file on the file system, and add the timestamp to the URL:

   /chrome/common/css/trac.css?1234567

That way, when the file actually changes, the URI used for the  
resource will change as to invalidate caches. When handling those  
requests, the extra parameter is simply ignored.

The obvious downside of this is that you need to stat all the static  
files as they are referenced.

An approach that might be cheaper performance-wise, but probably more  
complex to implement, would be to use the version of the component  
providing the static resource as parameter value. That way when you  
upgrade Trac or a plugin, the corresponding resource URLs will change.

Just some thoughts :)

Cheers,
Chris
--
Christopher Lenz
   cmlenz at gmx.de
   http://www.cmlenz.net/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to