I'm using an .htaccess file to allow my pages to call gzipped JavaScript files.
It works fine in ie8 & ff3, but the script is not loaded in Safari (or Chrome).
Here is the .htaccess file I'm using:
<files *.js.gz>
ForceType text/javascript
Header set Content-Encoding: gzip
</files>
Then, for example, I can call JS files from my HTML pages:
<script src="foo.js.gz"></script>
How can I modify the above .htaccess code to get it working for Safari (and still work for other browsers)?
I assume you're trying to use Gzip compression for faster downloads of assets and text content. It's a great technique for speeding up your site.
Safari, Chrome, and IE6 all have problems with Gzipped downloads. Also, Apache will do the gzip compression for you, there is no need to manually gzip files. Try this snippet:
That should safely gzip all text before it's sent out from Apache, and only for browsers that support it. You can link to JavaScript and other assets normally, just
myscript.js
, with no gz extension or compression on disk.