[wp-hackers] Re: Packing JavaScript

Alex Günsche ag.ml2007 at zirona.com
Thu Sep 20 15:51:09 GMT 2007

On Thu, 2007-09-20 at 09:21 -0500, Stephen Rider wrote:
> One more question:  Don't browsers cache javascript files?  Which to  
> my mind means that this would be (at worst) slow the first time you  
> load the page, but on subsequent loads it would pull from cache.
> Cache meaning:
> No http requests
> No bandwidth
> My understanding of this may be rough, so feel free to correct me. :)

Depends on server and client settings. If a server sends the proper
headers, and if the client has a strong caching policy, then you can
generally say yes. But my estimate is that on a large part of
constellations, there is no or suboptimal caching.

It's hard for me to provide actual figures, because I can only say what
I experience with my server and my browsers. I have an Apache 2.2.6
server with quite an out-of-the-box configuration, with regard to
caching. My browers are Konqueror 3.5.7 and FF on Linux. I have
set them both to caching, however none of them seem to cache JavaScript
files. For example, in Firefox, you can see cached files with
about:cache, and there's not a single JS file in my list. Maybe others
could also test and then post their server/client caching experience.

I think caching could be optimized with a combination of Cache-Control,
Expires, Last-Modified headers, and an appended version string to the JS
file. But for this, the JS file would have to be handled by WordPress to
modify the headers. Another cache optimization are If-None-Match and
ETag headers, although (a) they are rather the server's business, (b)
they require HTTP/1.1 and (c) they don't reduce the number of requests,
only the amount of data.

Kind regards,

Alex Günsche, Zirona OpenSource-Consulting
Blogs: http://www.zirona.com/ | http://www.regularimpressions.net
PubKey for this address: http://www.zirona.com/misc/ag.ml2007.asc

More information about the wp-hackers mailing list