Home · Latest · Trends  /  Apache
4

Leverage browser caching htaccess

rated 4 times [  4] [ 0]  / comments: 0 / hits: 1071  / 2 years ago, sat, jun 10, 2017, 03:16:28
How to leverage browser caching with htaccess
###You will need to make sure the following modules are enabled in httpd.conf

###LoadModule filter_module modules/mod_filter.so
###LoadModule deflate_module modules/mod_deflate.so  
###LoadModule deflate_module modules/mod_deflate.so

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access 1 year"
ExpiresByType text/html "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType application/pdf "access 1 year"
ExpiresByType font/truetype "access plus 1 year"
ExpiresByType font/opentype "access plus 1 year"
ExpiresByType application/x-font-woff   "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType text/x-javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"  
ExpiresByType application/x-javascript "access plus 1 year"
ExpiresByType application/x-shockwave-flash "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 year"
</IfModule>

##########################################

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
</IfModule>
More From » Apache
 

Comments

There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account
 
Share
Snippets
Install SpamAssassin and Exim on a CentOS
3 years ago, thu, sep 8, 2016
Common SSH commands for CSF [ConfigServer]
3 years ago, wed, dec 28, 2016
Simple CSS javascript social share buttons
3 years ago, tue, jan 3, 2017
Basic ClamAV antivirus engine SSH command line commands
3 years ago, thu, jan 19, 2017
CSF / LFD block force attacks on Exim Centos
2 years ago, mon, jun 26, 2017
Basic SSH Exim mail queue commands
2 years ago, sat, sep 2, 2017
2 years ago, tue, feb 27, 2018
2 years ago, wed, feb 28, 2018
Sponsor
Posted
paki

paki

Member since Sep 7, 2016
Total Code Snippets: 12
Total Comments: 0
Location: n/a
Following
User not following anyone yet.