Caching and gzip compression by htaccess

Can someone provide me with an optimize .htaccess configuration that handles compression, browser caching, proxy caching, etc. for a typical website?

Aside from my visitors, I'm also trying to make Google PageSpeed happy. I wanna use caching and gzip compression through .htaccess plz help me about it's code!

i want to cache icon,pdf,flv,jpg,png,gif,js,css,swf fiels for long time

i want to cache xml,txt files for 2 Days

i want to cache html files for 2 Days

and i wanna compress my html,txt,css,js,php files because those have large file size and is

there any way to gzip images by htaccess ?!

asked May 13, 2015 in htaccess by rajesh
0 votes

1 Answer

0 votes
 480 weeks

Header set Cache-Control "max-age=290304000, public"

# 2 DAYS

Header set Cache-Control "max-age=172800, public, must-revalidate"


Header set Cache-Control "max-age=7200, must-revalidate"

  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.*
answered May 13, 2015 by rajesh