I am looking to disable the gzip folder for folder xxx. looking in StackOverflow, I have tried this :
SetEnvIf Request_URI ^/xxx(.*) no-gzip dont-vary
But it doesn't work.
I have added in here :
<IfModule mod_deflate.c>
SetEnvIf Request_URI ^/flipbook(.*) no-gzip dont-vary
# enables the filter
SetOutputFilter DEFLATE
# non-textual entities should be already compressed
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
and even outside the mod_deflate module but nothing works.
Could anyone help?
SetEnvIf Request_URI ^/flipbook(.*) no-gzip dont-vary
This looks like it should work - for any URL that starts /flipbook
(case-sensitive). Setting the no-gzip
environment variable disables the DEFLATE filter of mod_deflate.
However, the (.*)
part on the regex is entirely superfluous. And, unless you are specifically using the dont-vary
env var in your own directives then this isn't doing anything. I don't think dont-vary
is a "special" Apache env var. Apache has force-no-vary
, which does what dont-vary
is probably intended to do, however, I don't believe you should be disabling the Vary
header anyway since mod_deflate applies the filter based on the Accept-Encoding
HTTP request header sent from the client, so any intermediary caching proxies should cache based on this header. (Only certain proxies have a problem with this header.)
So, this should be written:
SetEnvIf Request_URI "^/flipbook" no-gzip
Reference:
# enables the filter SetOutputFilter DEFLATE
This doesn't just "enable the filter", it enables the DEFLATE filter on all responses. This basically renders the AddOutputFilterByType
directives that follow superfluous, since you are already setting DEFLATE on everything. Generally, you don't want to set it on everything, which is presumably why you are using the AddOutputFilterByType
directives.
So, you probably don't need the SetOutputFilter
directive, if you are setting the DEFLATE on specific mime-types. OR, you use SetOutputFilter
and remove the AddOutputFilterByType
directives, but then you should still disable the filter on images and other already compressed media using the no-gzip
env var.
AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript
You don't need all 3. Your server is setting just one mime-type when sending JavaScript files - which you can see in the HTTP response. You only need that one. (Probably application/javascript
.)
Instead of setting the no-gzip
env var to disable mod_default, you could instead use an Apache <If>
expression to conditionally set the output filters only when not accessing URLs that start /flipbook
.
For example:
<If "%{REQUEST_URI} !~ m#^/flipbook/#">
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/javascript
</If>
You don't really need the <IfModule>
wrapper unless you intend to port the same code to multiple servers where mod_deflate might not be enabled (and that is acceptable).