Failing to turn-on the Gzip compression with .htaccess rules - Joomla! Forum - community, help and support


hi society!
i ran trouble trying turn on gzip compression.
the hosting provider has enabled these modules default: "mod_setenvif.c" & "mod_expires.c".
i had 2 variations of .htaccess rules, of them faled. what's wrong?
first variation:

code: select all

<ifmodule mod_deflate.c>
addoutputfilterbytype deflate text/plain text/html text/xml text/css
application/xml application/xhtml+xml application/rss+xml
application/javascript application/x-javascript

<ifmodule mod_setenvif.c>
browsermatch ^mozilla/4 gzip-only-text/html
browsermatch ^mozilla/4.0[678] no-gzip
browsermatch  msie !no-gzip !gzip-only-text/html
</ifmodule>
</ifmodule>
header set cache-control "max-age=43200"
# 1 year
<filesmatch ".(flv|ico|pdf|avi|mov|ppt|
doc|mp3|wmv|wav)$">
header set cache-control "max-age=29030400, public"
</filesmatch>
# 1 week
<filesmatch ".(jpg|jpeg|png|gif|swf)$">
header set cache-control "max-age=604800, public"
</filesmatch>
# 3 hour
<filesmatch ".(txt|xml|js|css)$">
header set cache-control "max-age=604800"
</filesmatch>
# never cache
<filesmatch ".(html|htm|php|cgi|pl)$">
header set cache-control "max-age=0, private, no-store, no-cache,
must-revalidate"

###2016
</filesmatch>

## expires caching ##
<ifmodule mod_expires.c>
expiresactive on
expiresdefault "access plus 1 month"
# css
expiresbytype text/css "access 1 month"
# data interchange
expiresbytype application/atom+xml "access plus 1 hour"
expiresbytype application/rdf+xml "access plus 1 hour"
expiresbytype application/rss+xml "access plus 1 hour"
expiresbytype application/json "access plus 0 seconds"
expiresbytype application/ld+json "access plus 0 seconds"
expiresbytype application/schema+json "access plus 0 seconds"
expiresbytype application/vnd.geo+json "access plus 0 seconds"
expiresbytype application/xml "access plus 0 seconds"
expiresbytype text/xml "access plus 0 seconds"
# favicon (cannot renamed!) , cursor images
expiresbytype image/vnd.microsoft.icon "access plus 1 week"
expiresbytype image/x-icon "access plus 1 week"
# html
expiresbytype text/html "access plus 0 seconds"
# javascript
expiresbytype application/javascript "access plus 1 year"
expiresbytype application/x-javascript "access plus 1 year"
expiresbytype text/javascript "access 1 month"
# manifest files
expiresbytype application/manifest+json "access plus 1 year"
expiresbytype application/x-web-app-manifest+json "access plus 0 seconds"
expiresbytype text/cache-manifest "access plus 0 seconds"
# media files
expiresbytype audio/ogg "access plus 1 month"
expiresbytype image/bmp "access plus 1 month"
expiresbytype image/gif "access plus 1 month"
expiresbytype image/jpeg "access plus 1 month"
expiresbytype image/png "access plus 1 month"
expiresbytype image/svg+xml "access plus 1 month"
expiresbytype image/webp "access plus 1 month"
expiresbytype video/mp4 "access plus 1 month"
expiresbytype video/ogg "access plus 1 month"
expiresbytype video/webm "access plus 1 month"
# web fonts
# embedded opentype (eot)
expiresbytype application/vnd.ms-fontobject "access plus 1 month"
expiresbytype font/eot "access plus 1 month"
# opentype
expiresbytype font/opentype "access plus 1 month"
# truetype
expiresbytype application/x-font-ttf "access plus 1 month"
# web open font format (woff) 1.0
expiresbytype application/font-woff "access plus 1 month"
expiresbytype application/x-font-woff "access plus 1 month"
expiresbytype font/woff "access plus 1 month"
# web open font format (woff) 2.0
expiresbytype application/font-woff2 "access plus 1 month"
# other
expiresbytype text/x-cross-domain-policy "access plus 1 week"

#additional
expiresbytype image/jpg "access 1 weeks"
expiresbytype application/pdf "access 1 month"
expiresbytype application/x-shockwave-flash "access 1 month"
</ifmodule>
## expires caching ##


the second:

code: select all


########## begin - etag optimization
## note: may cause problems on server , may need remove it
fileetag mtime size
########## end - etag optimization
########## begin - automatic compression of resources
addoutputfilterbytype deflate text/plain text/html text/xml text/css
application/xml application/xhtml+xml application/rss+xml
application/javascript application/x-javascript
########## begin - optimal default expiration time
## note: might cause problems , might have comment out by
## placing hash in front of section's lines

    # enable expiration control
    expiresactive on

    # default expiration: 1 hour after request
    expiresdefault "now plus 1 hour"

    # css , js expiration: 1 week after request
    expiresbytype text/css "now plus 1 week"
    expiresbytype application/javascript "now plus 1 week"
    expiresbytype application/x-javascript "now plus 1 week"

    # image files expiration: 1 month after request
    expiresbytype image/bmp "now plus 1 month"
    expiresbytype image/gif "now plus 1 month"
    expiresbytype image/jpeg "now plus 1 month"
    expiresbytype image/jp2 "now plus 1 month"
    expiresbytype image/pipeg "now plus 1 month"
    expiresbytype image/png "now plus 1 month"
    expiresbytype image/svg+xml "now plus 1 month"
    expiresbytype image/tiff "now plus 1 month"
    expiresbytype image/vnd.microsoft.icon "now plus 1 month"
    expiresbytype image/x-icon "now plus 1 month"
    expiresbytype image/ico "now plus 1 month"
    expiresbytype image/icon "now plus 1 month"
    expiresbytype text/ico "now plus 1 month"
    expiresbytype application/ico "now plus 1 month"
    expiresbytype image/vnd.wap.wbmp "now plus 1 month"
    expiresbytype application/vnd.wap.wbxml "now plus 1 month"
    expiresbytype application/smil "now plus 1 month"

    # audio files expiration: 1 month after request
    expiresbytype audio/basic "now plus 1 month"
    expiresbytype audio/mid "now plus 1 month"
    expiresbytype audio/midi "now plus 1 month"
    expiresbytype audio/mpeg "now plus 1 month"
    expiresbytype audio/x-aiff "now plus 1 month"
    expiresbytype audio/x-mpegurl "now plus 1 month"
    expiresbytype audio/x-pn-realaudio "now plus 1 month"
   expiresbytype audio/x-wav "now plus 1 month"

    # movie files expiration: 1 month after request
    expiresbytype application/x-shockwave-flash "now plus 1 month"
    expiresbytype x-world/x-vrml "now plus 1 month"
    expiresbytype video/x-msvideo "now plus 1 month"
    expiresbytype video/mpeg "now plus 1 month"
    expiresbytype video/mp4 "now plus 1 month"
    expiresbytype video/quicktime "now plus 1 month"
    expiresbytype video/x-la-asf "now plus 1 month"
    expiresbytype video/x-ms-asf "now plus 1 month"



waiting help!



p.s. final .htaccess looks like:

code: select all

########## begin - etag optimization
## note: may cause problems on server , may need remove it
fileetag mtime size
########## end - etag optimization
########## begin - automatic compression of resources
addoutputfilterbytype deflate text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
########## begin - optimal default expiration time
## note: might cause problems , might have comment out by
## placing hash in front of section's lines

   # enable expiration control
   expiresactive on
 
   # default expiration: 1 hour after request
   expiresdefault "now plus 1 hour"
 
   # css , js expiration: 1 week after request
   expiresbytype text/css "now plus 1 week"
   expiresbytype application/javascript "now plus 1 week"
   expiresbytype application/x-javascript "now plus 1 week"
 
   # image files expiration: 1 month after request
   expiresbytype image/bmp "now plus 1 month"
   expiresbytype image/gif "now plus 1 month"
   expiresbytype image/jpeg "now plus 1 month"
   expiresbytype image/jp2 "now plus 1 month"
   expiresbytype image/pipeg "now plus 1 month"
   expiresbytype image/png "now plus 1 month"
   expiresbytype image/svg+xml "now plus 1 month"
   expiresbytype image/tiff "now plus 1 month"
   expiresbytype image/vnd.microsoft.icon "now plus 1 month"
   expiresbytype image/x-icon "now plus 1 month"
   expiresbytype image/ico "now plus 1 month"
   expiresbytype image/icon "now plus 1 month"
   expiresbytype text/ico "now plus 1 month"
   expiresbytype application/ico "now plus 1 month"
   expiresbytype image/vnd.wap.wbmp "now plus 1 month"
   expiresbytype application/vnd.wap.wbxml "now plus 1 month"
   expiresbytype application/smil "now plus 1 month"
 
   # audio files expiration: 1 month after request
   expiresbytype audio/basic "now plus 1 month"
   expiresbytype audio/mid "now plus 1 month"
   expiresbytype audio/midi "now plus 1 month"
   expiresbytype audio/mpeg "now plus 1 month"
   expiresbytype audio/x-aiff "now plus 1 month"
   expiresbytype audio/x-mpegurl "now plus 1 month"
   expiresbytype audio/x-pn-realaudio "now plus 1 month"
   expiresbytype audio/x-wav "now plus 1 month"
 
   # movie files expiration: 1 month after request
   expiresbytype application/x-shockwave-flash "now plus 1 month"
   expiresbytype x-world/x-vrml "now plus 1 month"
   expiresbytype video/x-msvideo "now plus 1 month"
   expiresbytype video/mpeg "now plus 1 month"
   expiresbytype video/mp4 "now plus 1 month"
   expiresbytype video/quicktime "now plus 1 month"
   expiresbytype video/x-la-asf "now plus 1 month"
   expiresbytype video/x-ms-asf "now plus 1 month"

########## end - optimal expiration time


<ifmodule mod_deflate.c>

# force compression mangled `accept-encoding` request headers
# https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html

<ifmodule mod_setenvif.c>
   <ifmodule mod_headers.c>
      setenvifnocase ^(accept-encodxng|x-cept-encoding|x{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[x~-]{4,13}$ have_accept-encoding
      requestheader append accept-encoding "gzip,deflate" env=have_accept-encoding
   </ifmodule>
</ifmodule>


addoutputfilterbytype deflate "application/atom+xml" \
                       "application/javascript" \
                       "application/json" \
                       "application/ld+json" \
                       "application/manifest+json" \
                       "application/rdf+xml" \
                       "application/rss+xml" \
                       "application/schema+json" \
                       "application/vnd.geo+json" \
                       "application/vnd.ms-fontobject" \
                       "application/x-font-ttf" \
                       "application/x-javascript" \
                       "application/x-web-app-manifest+json" \
                       "application/xhtml+xml" \
                       "application/xml" \
                       "font/eot" \
                       "font/opentype" \
                       "image/bmp" \
                       "image/svg+xml" \
                       "image/vnd.microsoft.icon" \
                       "image/x-icon" \
                       "text/cache-manifest" \
                       "text/css" \
                       "text/html" \
                       "text/javascript" \
                       "text/plain" \
                       "text/vcard" \
                       "text/vnd.rim.location.xloc" \
                       "text/vtt" \
                       "text/x-component" \
                       "text/x-cross-domain-policy" \
                       "text/xml"


with pagespeedinsight throws less error, still remain.
but in developertools headers doesn't contain information regarding gzip.
so doubt work should be...

instead of trying set-up rules in htaccess why not turn on gzip in global configuration of joomla in server section?





Comments

Popular posts from this blog

Falang and too many redirects - Joomla! Forum - community, help and support

Infinite loop detected in JErrorInfinite loop detected in JError - Joomla! Forum - community, help and support

logged out from joomla! - Joomla! Forum - community, help and support