The document discusses HTTP caching as a way to improve performance. It describes different types of caches, including client caches, shared proxy caches, and gateway caches. Caching can save bandwidth and reduce response times. The document recommends using expiration dates and validation techniques like ETags and conditional GET requests to take advantage of caching. It provides code examples for setting cache headers and checking for stale content in Rails and Sinatra applications.
54. Gateway Cache
Bob Backend
GET /foo
GET /foo Host: foo.com
Host: foo.com If-None-Match: abcdef012345
55. Gateway Cache
Bob Backend
GET /foo
GET /foo Host: foo.com
Host: foo.com If-None-Match: abcdef012345
304NotModified
56. Gateway Cache
Bob Backend
GET /foo
GET /foo Host: foo.com
Host: foo.com If-None-Match: abcdef012345
304NotModified
200OK
ETag:abcdef012345
57. Rails: fresh_when
class FooController Application
def show
@foo = Foo.find(params[:id])
fresh_when :etag = @foo,
:last_modified = @foo.updated_at.utc
end
end
58. Rails: stale?
class FooController Application
def show
@foo = Foo.find(params[:id])
modified = @foo.updated_at.utc
if stale?(:etag = @foo, :last_modified = modified)
respond_to do |wants|
# ... normal response processing
end
end
end
end
#8: What we're talking about when we say HTTP caching.
There's so many different caching systems.
#9: Page caching, action caching, fragment caching, SQL caching, memcached.
#10: *This* is what we're talking about
Wire level
Declarative.
Don't worry if this doesn't look familiar.
#12: All caches adhere to the same basic rules for the most part.
#13: Or browser cache.
People are most familiar with. When we think about HTTP caching, this is what comes to mind.
Bandwidth/Traffic Reduction.
Number of Clients served by the Cache.
I don’t want to talk about Client caches.
#21: First server, client/browser, and web page
Things are good for, like, a year.
Ramble about research guys trading papers and linking to each other.
#23: State of the art
Roughly 2.3KB/s
Today, yahoo.com homepage is 388K - 2m48s
#24: Other things: CGI just starting out. (Guestbooks, hit counters, search)
JavaScript - didn’t exist.
So what was the most important issue to solve?