2013/11/13

Devoxx 2013: HTTP Caching in Practice

Xavier Coulon
types of cache:
  • local cache
  • proxy cache
  • gateway cache
  • (app cache -- custom built in the app)
http1.1 caching GET requests
  • expiration Last-Modified + Expires headers
  • If-Modified-Since header -> 304 not modified
  • ETag header
  • If-Match & 412 Precondition failed.
prevent inconsistencies: use explicit directives
  • Cache-Control
    • request header: no-cache, max-age, no-store, max-stale, min-fresh, no-transform & only ..
    • response: public, private, no-cache, proxy-revalidate, max-age,...
  • pragma header, request & response: no-cache: only for http 1.0 backwards compatiblity.
  • Refresh button in brower adds Cache-Control and Pragma headers to request. (not in Ajax requests!
java helpers:
  • Servlet Filter
  • JAX-RS 2.0: interceptors: Ajax-specific (e.g. add ETag + send Status.NOT_MODIFIED)
  • testing:
    • Arquillian (+ REST extension)
    • REST-assured
Https:
  • proxy caching doesn't work
  • decide on using http for static resources...
caching strategy:
  • static content:
    • max cache usage
    • enable gateway caching: Cache-Control: public, max-age
  • dynamic content:
    • timeout or ETag
RFC 2616 spec (http 1.1): http://www.ietf.org/rfc/rfc2616.txt

No comments: