Thu, December 2, 2021
 
https://devcodepro.comdevcodepro
X
InterServer Web Hosting and VPS
Home · Latest · Trends
5

Leverage browser caching htaccess

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>
rated 5 times (5) (0)
comments: 0 / hits: 2429  / 5 years ago, sat, jun 10, 17, 03:16:28
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
Login with Google
 
Share
Posted
paki
Member since Sep 7, 2016
Total Code Snippets: 12
Total Comments: 0
Location: n/a
paki snippets
5 years ago, thu, sep 8, 16, 3:04:22
comments: 0 / hits: 5482
5 years ago, wed, dec 28, 16, 4:11:52
comments: 2 / hits: 3974
5 years ago, tue, jan 3, 17, 3:37:12
comments: 0 / hits: 2366
5 years ago, thu, jan 19, 17, 5:40:32
comments: 0 / hits: 5924
5 years ago, mon, jun 26, 17, 9:21:15
comments: 0 / hits: 3458
4 years ago, sat, sep 2, 17, 4:26:09
comments: 1 / hits: 2618
4 years ago, tue, feb 27, 18, 9:25:15
comments: 0 / hits: 1863
4 years ago, tue, feb 27, 18, 9:41:12
comments: 0 / hits: 1878
4 years ago, wed, feb 28, 18, 11:02:34
comments: 0 / hits: 1859