0

I'm building a file server. It is currently serving downloadable files (.doc, .zip) perfectly using X-Send. It is possible to serve text based (css/javascript) or image files using x-send? My understanding is this the most efficient method available but I am always open to ideas.

The code I currently have...(tried various versions with lines commented out/in)

//header('Content-Disposition: inline; filename="' . basename($cacheFile) . '"');
header('Content-Type: text/css');
//header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
//header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT');
//header('Cache-Control: no-store, no-cache, must-revalidate');
//header('Pragma: no-cache'); 
//header('Content-Length: ' .(string)(filesize("./cache/".$cacheFile)));
header('X-Sendfile: /path/to/site.css'); 
hendr1x
  • 1,470
  • 1
  • 14
  • 23

1 Answers1

1

If you have static files, it would probably better to serve the files directly to avoid the overhead of going through the backend (php in your case).

However, mod_xsendfile will serve whatever file you throw at it unmodified, so it doesn't matter if your stuff is some binary format (.doc, .zip) or text format (.css, .js).

nmaier
  • 32,336
  • 5
  • 63
  • 78
  • Wow...thanks so much for answering. I'm using the file server to auto combine + mininify my css/js and do common image manipulation. I'm getting nothing using the code show above....any idea why? A tar file worked perfectly. – hendr1x Oct 03 '13 at 18:50
  • I have no way of telling what is happening... You should have a look at the log (debug LogLevel debug) – nmaier Oct 08 '13 at 17:40