Well I figured it out!

GTmetrix analyzes your website and you can see how many requests are being processed through GET commands to the web server. I just had to edit my .htaccess file. The inital load has 11 requests but the subsequent ones now have much less because gzip compression and mainly browser caching have been added to the .htaccess file. This lets the client computer store data that would normally be taken from the server on the initial load of the page. Once its loaded on the clients computer it no longer has to request that same GET command and reduces load on the server and the clients connection.

And here is what you add to that .htaccess file to enable these features for your webpage.

#compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

## EXPIRES CACHING ##

ExpiresActive On
ExpiresByType image/jpg “access plus 1 year”
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/pdf “access plus 1 month”
ExpiresByType text/x-javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 year”
ExpiresDefault “access plus 7 days”

## EXPIRES CACHING ##

Boom its that easy. Save that file and your good to go.

Another note is GTmetrix can sometimes have false positives. So my site grades a 97% pagespeed anda 96% Yslow but it says I could be doing more caching. This isnt true because google fonts are already cached. I can’t control the header of the google fonts but the header already has caching. I’m sure there are other false positives. Also I am no coder so the content “Remove query strings from static resources” will continue to have a low score. I’ll figure out how to edit that eventually. For now I’m pretty happy with the overall results. Now after the initial load I only see 1 GET request. Just as I thought it should have been to begin with.

Leave a Reply

Your email address will not be published. Required fields are marked *