In my opinion, page speed is one of the most difficult things to get right. If you have ever used a page speed analyzer and tried to follow its recommendations, you are probably already aware that some tasks offer marginal improvements in exchange for a lot of headache. I wanted to offer some insights from my own experiences in the hope that someone else who is frustrated will find this useful. Leveraging Browser Caching
Increase Site Speed
12
Code:
#enable expirations ExpiresActive On # expire GIF images after a month in the client's cache ExpiresByType image/gif A2592000 # expire PNG images after a month in the client's cache ExpiresByType image/png A2592000 # expire JPG after a month in the client's cache ExpiresByType text/jpg A2592000 # expire CSS images after a month in the client's cache ExpiresByType text/css A2592000 # expire HTML after a month in the client's cache ExpiresByType text/html A2592000 # expire JS after a month in the client's cache ExpiresByType text/javascript A2592000
Code:
<filesMatch "\.(js)$">
ExpiresDefault A29030400
</filesMatch>
<filesMatch "\.(jpg)$">
ExpiresDefault A29030400
</filesMatch> Code:
#Gzip <ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript </ifmodule> #End Gzip
Code:
<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|iso|tar|bz2|sit|rar|png|jpg|gif|jpeg|flv|swf)$ no-gzip dont-vary BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.[0678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48, the above regex won't work. You can use the following # workaround (comment the above line and uncomment the below line) to get the desired effect: # BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </IfModule>
- paulgl
- [2] replies
- Adam2
- TheContentAuthority
- [1] reply
- apnavarun
- challanger
- truvahorse
- TheContentAuthority
Next Topics on Trending Feed
-
12