Cache a page for less time than the period in which it changes

Consider a hypothetical news site. It has a front page (which we will call index.html) that includes a logo, and links to several articles. The front page changes daily, occasionally adding new articles and removing old ones. It also includes a financial page that displays the Dow Jones Average (updated every 20 minutes), and a personalized page that gives the weather report for a reader's zip code.

Pages on hypothetical news site

How would you want to cache this? Consider each section:

The logo is not going to change day-to-day. Or week-to-week, for that matter. You can safely give it a cache time of at least a week, and you could probably make it more, if you really wanted.

Your articles are not going to change, either. Sure, you will be putting up new ones every day, and taking down old stories after a while, but while they are up on your channel, they will still be the same old articles. So you can give them a cache time of 1 week as well.

The front page changes every day, so you do not want it to cache for more than 24 hours. And if there is late-breaking news, you will want this page to update at least a few times a day. A caching time of 1 hour is good.

Note

You will get dramatic performance improvements by increasing the caching age to 1 hour. After that, the improvements are not quite as dramatic.

The Dow Jones Average page would have a caching time of 20 minutes. If you felt like being especially clever, you could write a script to increase its caching time to several hours once the market closes.