3 comments

[ 7.2 ms ] story [ 31.9 ms ] thread
The correct use of caching can dramatically improve the performance of websites. Also knowing how to keep certain pages from ever being cached can be important too.

//php do not cache header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, s-maxage=0');

Recently I was dealing with someones crappy hand rolled PHP site that had terrible image performance. The images were being called from a database and had no-cache set?! While moving the images out of the database would most likely be the best thing to do, it was not worth the effort in this case. The images almost never change, old id's would be removed and new added. I modified the script that output images to send a s-maxage header of a sufficiently large value and put a instance of Varnish in front of the server. Server load dropped dramatically, response times dropped dramatically, and the maximum amounts of clients the server can withstand increased greatly.

Proper use of caching, either between your server and the database, inside your application, and between your server and the client can greatly reduce hardware requirements and response times. In finalizing your application before full deployment always validate your http headers to your clients are doing what you expect them too.

A tool like YSlow in the browser, or http://WebPagetest.org will show you what is cached and what isn't

WebPagetest.org shows you the first time call which is generally awesome, but in this context will also show you the second visit experience which takes into account the content cache settings.