[wp-hackers] Packing JavaScript

Charles lists07 at wiltgen.net
Wed Sep 19 19:57:55 GMT 2007


>>> That's damned clever.
>>
>> True, but you have to be careful that solutions like this properly set
the
>> cache control headers so that the requested files get cached by the
browser.
>
> I'm not 100% familiar with the details of the cache control header,
> but what more would you need than Cache-Control: public?

This is from <http://www.julienlecomte.net/blogfiles/gz.phps>, which I know
works:

  /*
   * Set the HTTP response headers that will
   * tell the client to cache the resource.
   */

  $file_last_modified = filemtime( $src_uri );
  header( "Last-Modified: " . date( "r", $file_last_modified ) );

  $max_age = 300 * 24 * 60 * 60; // 300 days

  $expires = $file_last_modified + $max_age;
  header( "Expires: " . date( "r", $expires ) );

  $etag = dechex( $file_last_modified );
  header( "ETag: " . $etag );

  $cache_control = "must-revalidate, proxy-revalidate, max-age=" . $max_age
. ", s-maxage=" . $max_age;
  header( "Cache-Control: " . $cache_control );

-- Charles




More information about the wp-hackers mailing list