hi,

I try to use fileframework/bitcache as a replacement for the image module. I notice that images served through the fileframework do not cached in the browser, probably because the response headers for such images contain
store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=1209600
Can this be changed so that stuf from fileframework adheres to the caching settings that are defined in the "Performance" setting?

thanks

Comments

miglius’s picture

Project: File Framework » Bitcache

Maybe a bitcache could adjust headers so that content pulled from the bitcache would get cached in the browser by default? The content is referenced by it's hash so it's not likely that it will change or expire :).

Arto’s picture

Assigned: Unassigned » Arto
Status: Active » Fixed

Those headers are not set by Bitcache, but rather by Drupal's core code. In release 6.x-1.0-alpha3 I've overridden the Cache-Control, Expires and Last-Modified headers set by Drupal; the relevant file is bitcache.server.inc (around line 126, in this release) and the relevant bits of the HTTP spec are:

In this latest release, the Bitcache module outputs a Cache-Control header of "private, no-transform" and an Expires header per 14.21 of the spec: "To mark a response as 'never expires,' an origin server sends an Expires date approximately one year from the time the response is sent."

This can still be much improved upon, especially by implementing full support for conditional ETag requests (the SHA-1 checksums of bitstreams conveniently serve as strong entity tags), but it's already a far sight better than the previous headers that were preventing caching altogether.

Suggestions and patches for further improvements would be most welcome.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

jvieille’s picture

Issue summary: View changes

Works great. I had to modify Boost for the same with this module
I added this function in boost.module

function boost_htaccess_bitcache_dir_put() {
  // Server is not apache; do nothing
  if (stristr($_SERVER["SERVER_SOFTWARE"], 'apache') == FALSE) {
    return TRUE;
  }

  // Get some info
  $bitcache_dir = BOOST_ROOT_CACHE_DIR ."/normal/www.see.asso.fr/bitcache";
  $filename = $bitcache_dir . '/.htaccess';
    $generated = '<FilesMatch "\.((html|xml|jpeg|png|gif|pdf|swf|mp3|json))$">' . "\n";    
    $generated .= "  <IfModule mod_headers.c>\n";
    $generated .= "    Header unset Last-Modified\n";
    $generated .= '    Header set Expires "'  . gmdate('D, d M Y H:i:s', time() + 365 * 86400) . ' GMT"' . "\n";
    $generated .= '    Header set Cache-Control "private, no-transform"' . "\n";
    $generated .= "  </IfModule>\n";
    $generated .= "</FilesMatch>\n";
    $htaccess = file_exists($filename) ? file_get_contents($filename) : FALSE;

  // htaccess exists and has the correct contents
  if ($htaccess && strcmp($htaccess, $generated) === 0) {
    return TRUE;
  }
  // cache dir doesn't exist, try to create it; if no go, bail out.
  if (!is_dir($bitcache_dir) && !_boost_mkdir_p($bitcache_dir)) {
    return FALSE;
  }

  // cache dir htaccess is not there, create it.
  $result = file_put_contents($filename, $generated);
  if ($result) {
    return $result;
  }
  else {
    return FALSE;
  }
}

and added the call beside the existing boost_htaccess_cache_dir_put() in boost.module and boost.admin.inc