Live data from Hacker News

How To Optimize Your Site With HTTP Caching

betterexplained.com

1–10 of 30 posts

Re: How To Optimize Your Site With HTTP Caching

#6
post #3

This is a great article for an introduction to HTTP caching. It's well-written and even covers how to set up caching in Apache.

Thanks for the kind words (I'm the author). My main, ever-evolving goal when writing tutorials is to try to write what I'd like to see:

1) Explain the underlying concept

2) Show variations

3) Explain how to do it yourself

4) Show how to verify you did it correctly

5) Meta: be as concise as possible, maximize bang for the buck

Re: How To Optimize Your Site With HTTP Caching

#7
post #2

Article from 2007

Yep, I was surprised too to see it on HN :).

I think one of the meta-takeaway is that understanding the fundamentals of web caching can help with your general CS knowledge ("There are only two hard problems in Computer Science: cache invalidation and naming things." -- Phil Karlton).

Looking at Apache, we see a few strategies:

  * Include last-modified metadata
  * Include content metadata (eTag/md5 of content)
  * Include explicit expiration date
  * Include a max-age
  * Include metadata about who can cache (public/private/no-caching, i.e. users can cache but proxies cannot)
These approaches could be used when designing data flows with Memcache, Redis, etc.

Re: How To Optimize Your Site With HTTP Caching

#8
post #7
post #2

Article from 2007

Yep, I was surprised too to see it on HN :). I think one of the meta-takeaway is that understanding the fundamentals of web caching can help with your general CS knowledge ("There are only two hard problems in Computer Science: cache invalidation and naming things." -- Phil Karlton). Looking at Apache, we see a few strategies: * Include last-modified metadata * Include content metadata (eTag/md5 of content) * Include…

One thing I don't understand. If the server has asked the client to cache an image for a year, and the image is indeed updated in that time, is there some way of telling the client to download that image anyway?

I'd take it to Google, but I have no idea how I'd ask that in Google query form.

Re: How To Optimize Your Site With HTTP Caching

#9
post #7

Earlier quoted context omitted.

Yep, I was surprised too to see it on HN :). I think one of the meta-takeaway is that understanding the fundamentals of web caching can help with your general CS knowledge ("There are only two hard problems in Computer Science: cache invalidation and naming things." -- Phil Karlton). Looking at Apache, we see a few strategies: * Include last-modified metadata * Include content metadata (eTag/md5 of content) * Include…

One thing I don't understand. If the server has asked the client to cache an image for a year, and the image is indeed updated in that time, is there some way of telling the client to download that image anyway? I'd take it to Google, but I have no idea how I'd ask that in Google query form.

In HTTP, since it's stateless, you don't "tell" the client anything without it first asking. The usual way to bust the cache is to add a junk parameter to the end of a GET request.

Re: How To Optimize Your Site With HTTP Caching

#10
post #7

Earlier quoted context omitted.

Yep, I was surprised too to see it on HN :). I think one of the meta-takeaway is that understanding the fundamentals of web caching can help with your general CS knowledge ("There are only two hard problems in Computer Science: cache invalidation and naming things." -- Phil Karlton). Looking at Apache, we see a few strategies: * Include last-modified metadata * Include content metadata (eTag/md5 of content) * Include…

One thing I don't understand. If the server has asked the client to cache an image for a year, and the image is indeed updated in that time, is there some way of telling the client to download that image anyway? I'd take it to Google, but I have no idea how I'd ask that in Google query form.

This is actually referenced in the article. You can use the Last-Modified date and the server will either return a 304 (Not Modified) or the modified image if it is newer.
Post reply on HN