Speeding up Websites, Part 2

As promised in my previous post, I am including the code we use to cache our website. (I got this from a Google Group discussion.) Further explanation can be found from Google’s help page: https://code.google.com/speed/page-speed/docs/caching.html.

Most web pages include resources that change infrequently, such as CSS files, image files, JavaScript files, and so on. These resources take time to download over the network, which increases the time it takes to load a web page. HTTP caching allows these resources to be saved, or cached, by a browser or proxy. Once a resource is cached, a browser or proxy can refer to the locally cached copy instead of having to download it again on subsequent visits to the web page. Thus caching is a double win: you reduce round-trip time by eliminating numerous HTTP requests for the required resources, and you substantially reduce the total payload size of the responses. Besides leading to a dramatic reduction in page load time for subsequent user visits, enabling caching can also significantly reduce the bandwidth and hosting costs for your site.

Basically, the .htaccess file is telling the bots to cache certain files at various times for returning visitors.

ExpiresActive On
ExpiresDefault A0

<FilesMatch “.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$”>
ExpiresDefault A29030400
Header append Cache-Control “public”
</FilesMatch>

<FilesMatch “.(gif|jpg|jpeg|png|swf)$”>
ExpiresDefault A604800
Header append Cache-Control “public”
</FilesMatch>

<FilesMatch “.(xml|txt|html|js|css)$”>
ExpiresDefault A7200
Header append Cache-Control “proxy-revalidate”
</FilesMatch>

<FilesMatch “.(php|cgi|pl|htm)$”>
ExpiresActive Off
Header set Cache-Control “private, no-cache, no-store, proxy-revalidate, no-transform”
Header set Pragma “no-cache”

</FilesMatch>

Posted in

Christina Hawkins

Since 1999, Christina has been designing and building exceptional websites. With many years of experience in creating thousands of websites, she understands the need for continuing education in her field and, therefore, is constantly learning and teaching others about internet marketing and digital processes. Christina is known for her highly-collaborative methods that help her realize the vision each customer has to successfully create engaging content to captivate targeted audiences across multiple platforms. Christina has honed her digital marketing and graphic design skills so that she can help B2B industries get their message out to their target audience in the right way. In addition to her ability as a digital marketer, Christina serves as a coach and mentor with WPElevation to other digital marketing freelancers, helping them grow their businesses. She is also a sponsor and co-leader of Houston's WordPress Meetup.

Leave a Comment





Do NOT follow this link or you will be banned from the site!