Sunday, March 9, 2014

Enabling or Forcing browser caching for static contents from HTTP Server (web server) application server.

Below post will help in caching static content at browser level so that you can leverage webserver from loading the same.
 
If you encounter web application performance issues due to frequent static content loading (jpg/css/etc) files. when browser always making requests to web servers for rendering static contents. the response time will be really bad. you will see in background multiple httpd process running at server and consuming high CPU due to this.

#*********Add in http.conf file ***********#
#*********Expiring the content ************#


ExpiresActive on
ExpiresByType image/gif A2592000
ExpiresByType image/jpg A2592000
ExpiresByType text/css A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType application/x-javascript A2592000
 

#****************browser caching*************
Header unset Pragma
Header unset Cache-Control
Header append Cache-Control "max-age=604800"

<FilesMatch ".(html|htm|do|jsp|gsp|text)$">
Header set Cache-Control "no-cache, no-store, must-revalidate"
</FilesMatch>

<Location /em>
ExpiresActive on
Header append cache-control "no-cache, max-age=0, must-revalidate, proxy-revalidate"
</Location>


Header unset Pragma
Header unset Cache-Control
Header append Cache-Control "max-age=604800"
<FilesMatch ".(html|htm|do|jsp|gsp)$">
Header set Cache-Control "no-cache, no-store, must-revalidate"
</FilesMatch>
ExpiresActive on
ExpiresByType image/gif A2592000
ExpiresByType image/jpg A2592000
ExpiresByType text/css A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType application/x-javascript A2592000

No comments:

Post a Comment