Search code examples
apache.htaccessheadergzipmod-deflate

mod_deflate: 'Vary' header not set but unsettable for .css and .js files


I'm setting a website hosted on Apache/2.2.17. I don't have access to apache's installation directory nor httpd.conf file (just www folder with eventually some .htaccess files).

I've got gzip compression enabled but .css and .js (the others files than images and .php files I've tested so far) response doesn't have got the Vary: Accept-Encoding header as expected even if they have the Content-Encoding: gzip header.

I can't force it via .htaccess file with Header set Vary Accept-Encoding nor Header append Vary Accept-Encoding with or without semi-colon after Vary (I can't even append User-Agent to it).

Thanks.

UPDATE:

Here's my .htaccess file

ErrorDocument 404 404.php

# Permissions
Order Allow,Deny
Allow from all
RedirectMatch 403 /(data|private)/

# Index
DirectoryIndex index.php
Options -All

# Set/Add Headers
AddDefaultCharset utf-8
Header set Cache-Control no-store
Header set Connection keep-alive

Header set Vary Accept-Encoding
SetEnvIfNoCase Request_URI "\.php" mvary
Header append Vary User-Agent env=mvary

# Remove Headers
ExpiresActive Off
FileETag None
Header unset ETag
Header unset Expires
Header unset Last-Modified
Header unset Pragma
Header unset X-Powered-By

Here are loaded modules:

core mod_authn_file mod_authn_default mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_default mod_auth_basic mod_dbd mod_include mod_filter mod_log_config mod_env mod_expires mod_headers mod_setenvif mod_version prefork http_core mod_mime mod_status mod_autoindex mod_asis mod_info mod_negotiation mod_dir mod_actions mod_alias mod_rewrite mod_so mod_php5 mod_ruid2 mod_deflate mod_remoteip mod_binary mod_tonyscanner


Solution

  • mod_deflate won't compress non-html file that are too "light", but CloudFlare will (without always? adding the Vary: Accept-Encoding header).