Cache Components As Long As Possible
The best way to improve performance of an action is to not perform the action. Zero sounds like a great performance measurement! When it comes to the journey a response makes from a server to a client, the best possible performance is to eliminate the journey completely.
If the browser would be so kind as to store the component locally, it could reuse that component in the future instead of downloading it again. In fact, browsers can do this. All they need to know is how long to cache the component before re-requesting it from the server. The browser cannot be expected to know when the component changes, so the server has to tell it. This caching process happens on the client’s machine, but is under the server’s control.
HTML caching is inappropriate if the page changes dynamically or frequently. It also interferes with page statistics because it hides user hits from the server. For these reasons, it is often more appropriate to make the HTML non-cacheable and to place all cacheable components in external files.
How To Implement HTML Caching
Server-side scripting languages (e.g., PHP, ASP) provide a way to set headers for the current HTML page. Use it to include either the expires or cache-control: max-age header line. Expires allows us to set an expiry date; cache-control: max-age allows us to set a duration (length of time from access date to expiry date).
How To Implement Other Caching
ExpiresActive On ExpiresByType image/gif "access plus 1 year" ExpiresByType application/ecmascript M86400 ExpiresDefault A3600
Keep in mind that .htaccess applies to the directory it is in and to all subdirectories below it.
Caching Tutorial for Web Authors and Webmasters by Mark Nottingham. Published 2010.06.29 by Mark Nottingham at www.mnot.net/cache_docs. Accessed 2011.12.14.
Optimize Caching. Published by Google at code.google.com/speed/page-speed/docs/caching.html. Accessed 2011.12.14. This is a detailed explanation of HTTP caching and a how-to tutorial.
Website Performance: Taxonomy of Tips by Warren Gaebel. Published 2011.12.29 by Monitis at blog.mon.itor.us/2011/12/website-performance-taxonomy-of-tips. Accessed 2012.01.02
YSlow Ruleset Matrix. Published by Yahoo at developer.yahoo.com/yslow/matrix. Accessed 2011.11.30. Yahoo’s implicit rankings can be inferred from the second column of the table (weight). The bigger the number, the more important Yahoo considers the tip to be.
Try Monitis For Free. A 15-day free trial. Your opportunity to see how easy it is to use the Monitis cloud-based monitoring system. Credit card not required.
The Monitis Exchange at GitHub. This is the official repository for scripts, plugins, and SDKs that make it a breeze to use the Monitis system to its full potential.