.htaccess - Gzip compression and cache expiration not working -
i have configured cache expiration , gzip compression in .htaccess file not working according yslow chrome extension stats.
here .htaccess
# ---------------------------------------------------------------------- # mod rewrite # ---------------------------------------------------------------------- <ifmodule mod_rewrite.c> options -multiviews rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] </ifmodule> # ---------------------------------------------------------------------- # gzip compression # ---------------------------------------------------------------------- <ifmodule mod_gzip.c> mod_gzip_on yes mod_gzip_dechunk yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^content-encoding:.*gzip.* </ifmodule> # ---------------------------------------------------------------------- # expires headers (for better cache control) # ---------------------------------------------------------------------- <ifmodule mod_expires.c> expiresactive on # document html expiresbytype text/html "access plus 0 seconds" # media: images, video, audio expiresbytype audio/ogg "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 video/mp4 "access plus 1 month" expiresbytype video/ogg "access plus 1 month" expiresbytype video/webm "access plus 1 month" # css , javascript expiresbytype application/javascript "access plus 1 year" expiresbytype text/css "access plus 1 year" </ifmodule> note: i'm using xampp
this first post here!
for cache expiration:
did check if module "mod_expires.so" enabled in apache/conf/httpd.conf? search line #loadmodule expires_module modules/mod_expires.soand remove "#" sign. after should work.
for gzip compression:
i use "mod_deflate" enable compression. use "mod_mime", "mod_setenvif" , "mod_headers". check each enabled in httpd.conf. combination works me.
htaccess compression:
<ifmodule mod_mime.c> addtype application/x-javascript .js addtype text/css .css </ifmodule> <ifmodule mod_deflate.c> setoutputfilter deflate <ifmodule mod_setenvif.c> setenvifnocase request_uri \.(?:rar|zip)$ no-gzip dont-vary setenvifnocase request_uri \.(?:gif|jpg|png)$ no-gzip dont-vary setenvifnocase request_uri \.(?:avi|mov|mp4)$ no-gzip dont-vary setenvifnocase request_uri \.mp3$ no-gzip dont-vary </ifmodule> <ifmodule mod_setenvif.c> browsermatch ^mozilla/4 gzip-only-text/html browsermatch ^mozilla/4\.0[678] no-gzip browsermatch \bmsie !no-gzip !gzip-only-text/html </ifmodule> <ifmodule mod_headers.c> header append vary user-agent env=!dont-vary </ifmodule> </ifmodule> more information here. hope helps.
Comments
Post a Comment