<FilesMatch "(\.js\.gz|\.css\.gz)$"> # Serve correct encoding type. Header append Content-Encoding gzip # Force proxies to cache gzipped & non-gzipped css/js files separately. Header append Vary Accept-Encoding </FilesMatch>
The above code use
append rather than
set in serving the correct encoding type, I check for documentation here - http://httpd.apache.org/docs/current/mod/mod_headers.html#Header and instead of
append we can use
The problem I've encountered in
Header append Content-Enocding gzip is I can't enable CSS and JS aggregation in Drupal performance page, the site breaks if it is installed in a Apache server which is already doing a gzip compression, the gzip in the header sent to the browser appear to be twice or appended, I attached screen-shot that can be found here to best describe the problem:
This happens if Drupal is installed in a sub domain, a sub directory or in a multi-site setup site created using symbolic link, I have tested it in those situation. If Drupal is installed in the root directory, it seems not affected by the problem, to verify this problem I have setup a fresh install of a Drupal 7 site located here - > http://d7.levinson.com.ph
Login with user : admin/admin
go to configuration > performance
then turn on CSS / JS aggregation
VIOLA - the site is broken!
No effects even if you clear the cache several times.
Changing the code
# Serve correct encoding type. Header append Content-Encoding gzip
# Serve correct encoding type. Header set Content-Encoding gzip
seems to solve the problem.
PASSED: [[SimpleTest]]: [MySQL] 33,554 pass(es). View
PASSED: [[SimpleTest]]: [MySQL] 33,545 pass(es). View
PASSED: [[SimpleTest]]: [MySQL] 31,939 pass(es). View