SlideShare a Scribd company logo
HTTP headers that make your website go faster
Slow websites
SUCK
WEB PERFORMANCE IS AN
ESSENTIAL PART OF THE
USER EXPERIENCE
SLOW~DOWN
HTTP headers that make your website go faster
HTTP headers that make your website go faster
HTTP headers that make your website go faster
THROWING
SERVERS
ATTHEPROBLEM
MO' MONEY
MO' SERVERS
MO' PROBLEMS
IDENTIFY SLOWEST PARTS
OPTIMIZE
AFTER A WHILE YOU HIT THE LIMITS
CACHE
HI, I'M THIJS
I'M THE TECH
EVANGELIST
AT
HTTP headers that make your website go faster
HTTP headers that make your website go faster
HTTP headers that make your website go faster
WE MAKE THE
WEB FASTER
WE ENHANCE DIGITAL EXPERIENCES
BY LOWERING NETWORK LATENCY
WE BUILD SOFTWARE-DEFINED
WEB ACCELERATION & CONTENT
DELIVERY SOLUTIONS
1.3 Tbps
per server
1.17 Gbps
per watt
ACHIEVE GROWTH, PERFORMANCE &
SUSTAINABILITY GOALS
WORLD’S FASTEST EDGE CONTENT DELIVERY SOFTWARE
HTTP headers that make your website go faster
HTTP headers that make your website go faster
CACHING
WHY
CACHE
HIGHER
CONCURRENCY
HIGHER
THROUGHPUT
LOWER LATENCY
IMPROVE QUALITY OF EXPERIENCE
WHY
RECOMPUTE
IF THE DATA
HASN'T
CHANGED?
DIFFERENT KINDS OF CACHING
✓ LOCAL KEY-VALUE STORE
✓ FILE CACHE
✓ DISTRIBUTE CACHE
✓ BROWSER CACHE
✓ REVERSE CACHING PROXY
✓ CONTENT DELIVERY NETWORK
HTTP headers that make your website go faster
USER SERVER
USER SERVER
BROWSER CACHE
USER SERVER
SERVER CACHE
UNDER PRESSURE
SERVER
USER PROXY SERVER
USER PROXY SERVER
REVERSE
CACHING
PROXY
USER PROXY SERVER
THE EDGE
USER VARNISH SERVER
THE EDGE
USER VARNISH SERVER
THE ORIGIN
HTTP headers that make your website go faster
HTTP headers that make your website go faster
EVERY
IMPLEMENTATION
HAS ITS OWN
CACHE POLICY
CONFIGURATION
HTTP HAS CONVENTIONAL
BUILT-IN CACHING
MECHANISMS
Expires: Mon, 20 Feb 2023 21:31:06 GMT
LIMITED OPTIONS
Cache-Control: public, max-age=500
Cache-Control: private, no-cache, no-store
KEY CACHING CONCEPTS
CACHING
HOLD THE RESPONSE AND SERVE IT AGAIN UPON
SUBSEQUENT REQUESTS
PRIVATE CACHE
A CACHE THAT EXISTS IN THE CLIENT.
E.G. A LOCAL DEVICE OR BROWSER CACHE.
STORES DATA FOR A SINGLE USER.
SHARED CACHE
A CACHE THAT SERVES MULTIPLE USERS.
USUALLY A CACHING PROXY OR CDN.
YOU SHOULD AVOID STORING PERSONALIZED DATA.
TIME TO LIVE
THE AMOUNT OF SECONDS AN OBJECT IS
CONSIDERED FRESH.
FRESH CONTENT
CACHED OBJECT HASN'T EXPIRED YET.
RESPONSE CAN BE REUSED FOR SUBSEQUENT
REQUESTS.
STALE CONTENT
EXPIRED CONTENT THAT SHOULD BE REVALIDATED
BEFORE SERVING. IS NOT DIRECTLY REMOVED FROM
THE CACHE.
REVALIDATE CONTENT
ASK THE ORIGIN SERVER IF THE REQUESTED OBJECT
IS STILL FRESH.
CACHE-CONTROL RESPONSE DIRECTIVES
✓ PRIVATE
✓ PUBLIC
✓ IMMUTABLE
✓ MAX-AGE
✓ S-MAXAGE
✓ NO-CACHE
✓ NO-STORE
✓ NO-TRANSFORM
✓ MUST-REVALIDATE
✓ PROXY-REVALIDATE
✓ MUST-UNDERSTAND
✓ STALE-WHILE-REVALIDATE
✓ STALE-IF-ERROR
Cache-Control: public
Cache-Control: public
CACHING ALLOWED, BOTH BY PRIVATE & SHARED CACHES
Cache-Control: public
CACHING ALLOWED, BOTH BY PRIVATE & SHARED CACHES
PROXY
SERVERS
BROWSER
USER PROXY SERVER
PUBLIC
CACHE
PRIVATE
CACHE
Cache-Control: private
Cache-Control: private
CACHING ALLOWED, BUT ONLY BY PRIVATE CACHES
Cache-Control: private=Set-Cookie
Cache-Control: private=Set-Cookie
CACHING ALLOWED BY ALL CACHES, UNLESS A SET-COOKIE
HEADER IS SET. THEN THE RESPONSE IS ONLY HANDLED BY
PRIVATE CACHES
Cache-Control: public, max-age=100
Cache-Control: public, max-age=100
ALL CACHES ALLOWED.
CONTENT IS FRESH FOR 100 SECONDS.
Cache-Control: private, max-age=100
Cache-Control: private, max-age=100
ONLY PRIVATE CACHES ALLOWED.
CONTENT IS FRESH FOR 100 SECONDS.
Cache-Control: public, s-maxage=100
Cache-Control: public, s-maxage=100
ALL CACHES ALLOWED.
CONTENT IN SHARED CACHES IS FRESH FOR 100 SECONDS.
Cache-Control: public, max-age=60, s-maxage=100
Cache-Control: public, max-age=60, s-maxage=100
ALL CACHES ALLOWED.
CONTENT IN PRIVATE CACHES IS FRESH FOR 60 SECONDS.
CONTENT IN SHARED CACHES IS FRESH FOR 100 SECONDS.
Cache-Control: public, max-age=60
Age: 40
AGE HEADER DESCRIBES THE TIME IN SECONDS
THE OBJECT WAS IN A PROXY CACHE.
Remaining TTL = TTL - Age
REVALIDATION
USER PROXY ORIGIN
IS THE
CONTENT STILL
FRESH?
PROXY ORIGIN
GET / HTTP/1.1
HTTP/1.1 200 OK
CONDITIONAL REQUESTS
HTTP/1.1 304 Not Modified
CONDITIONAL REQUESTS
HTTP/1.1 200 OK
Host: localhost
Etag: 7c9d70604c6061da9bb9377d3f00eb27
Content-type: text/html; charset=UTF-8
Hello world output
GET / HTTP/1.1
Host: localhost
CONDITIONAL REQUESTS
HTTP/1.1 304 Not Modified
Host: localhost
Etag: 7c9d70604c6061da9bb9377d3f00eb27
GET / HTTP/1.1
Host: localhost
If-None-Match: 7c9d70604c6061da9bb9377d3f00eb27
CONDITIONAL REQUESTS
HTTP/1.1 200 OK
Host: localhost
Last-Modified: Fri, 22 Jul 2016 10:11:16 GMT
Content-type: text/html; charset=UTF-8
Hello world output
GET / HTTP/1.1
Host: localhost
CONDITIONAL REQUESTS
HTTP/1.1 304 Not Modified
Host: localhost
Last-Modified: Fri, 22 Jul 2016 10:11:16 GMT
GET / HTTP/1.1
Host: localhost
If-Last-Modified: Fri, 22 Jul 2016 10:11:16 GMT
VALIDATE
QUICKLY
EARLY
STORE &
RETRIEVE
ETAG
ASYNCHRONOUS
REVALIDATION
USER PROXY ORIGIN
ASYNC FETCH
SEND STALE
RESPONSE WHILE
FETCHING
Cache-Control: public, max-age=3600, stale-
while-revalidate=100
Cache-Control: public, max-age=3600, stale-
while-revalidate=100
ALL CACHES ALLOWED.
CONTENT IS FRESH FOR 1 HOUR.
STALE CONTENT CAN BE SERVED UP TO 100 SECONDS PAST
THE TTL WHILE DOING AN ASYNCHRONOUS REVALIDATION.
USER PROXY ORIGIN
FETCH FAILED
SEND STALE
RESPONSE WHILE
FETCHING FAILS
Cache-Control: public, max-age=3600, stale-
if-error=86400
Cache-Control: public, max-age=3600, stale-
if-error=86400
ALL CACHES ALLOWED.
CONTENT IS FRESH FOR 1 HOUR.
STALE CONTENT CAN BE SERVED UP TO 1 DAY PAST THE TTL
WHILE THE ORIGIN IS UNREACHABLE.
Fresh = TTL > 0
Async revalidation = TTL + stale > 0
Synchronous revalidation = TTL + stale <= 0
Fresh = TTL > 0
Async revalidation = TTL + stale > 0
Synchronous revalidation = TTL + stale <= 0
REVALIDATION
CAN BE DONE
CONDITIONALLY
Cache-Control: public, max-age=3600, must-revalidate
Cache-Control: public, max-age=3600, must-revalidate
ALL CACHES ALLOWED.
CONTENT IS FRESH FOR 1 HOUR.
SERVING STALE CONTENT NOT ALLOWED.
Cache-Control: public, max-age=3600, proxy-revalidate
Cache-Control: public, max-age=3600, proxy-revalidate
SAME AS MUST-
REVALIDATE BUT FOR
PROXY SERVERS
Cache-Control: public, max-age=86400, immutable
Cache-Control: public, max-age=86400, immutable
ALL CACHES ALLOWED.
CONTENT IS FRESH FOR 1 DAY.
CONTENT WILL NOT BE UPDATED WHILE FRESH
Cache-Control: public, max-age=86400, immutable
ALL CACHES ALLOWED.
CONTENT IS FRESH FOR 1 HOUR.
CONTENT WILL NOT BE UPDATED WHILE FRESH
USEFUL FOR
BROWSER CACHING
Cache-Control: public, immutable
DATA IS
IMMUTABLE, ASSUME
HIGH TTL IN PROXY
CONTEXT
Cache-Control: public, max-age=3600, no-transform
Cache-Control: public, max-age=3600, no-transform
ALL CACHES ALLOWED.
CONTENT IS FRESH FOR 1 HOUR.
CONTENT CANNOT BE TRANSFORMED
BY INTERMEDIARY CACHES
Cache-Control: public, max-age=3600, no-transform
EDGE COMPUTE
Cache-Control: no-cache
Cache-Control: no-cache
STORE OBJECT IN CACHE
BUT REVALIDATE BEFORE EVERY REUSE
Cache-Control: no-cache=Set-Cookie
STORE OBJECT IN CACHE
BUT REVALIDATE BEFORE EVERY REUSE
IF THE SET-COOKIE HEADER IS SET
Cache-Control: no-store
Cache-Control: no-store
DON'T STORE OBJECT IN THE CACHE
Cache-Control: private, no-cache, no-store
TYPICAL ONE
CACHE VARIATIONS
Vary: Accept-Language
‣ http://test.com/
-Accept-Language: fr
-Accept-Language: nl
-Accept-Language: en
GET / HTTP/1.1
Host: test.com
Accept-Language: fr
GET / HTTP/1.1
Host: test.com
Accept-Language: en
Vary: Accept-Encoding, Accept-Language,
X-Forwarded-Proto
SURROGATES
THE EDGE
CONTENT
DELIVERY
NETWORK
USER EDGE ORIGIN
THE EDGE IS NO LONGER IN THE ORIGIN DATA CENTER
USER EDGE ORIGIN
THE EDGE MOVES CLOSER TO THE END USER
USER EDGE ORIGIN
MULTIPLE EDGES
USER EDGE
Surrogate-Control: max-age=300
Surrogate-Control: max-age=300+100
Surrogate-Control: max-age=300+100
STALENESS
Surrogate-Control: no-store
Surrogate-Control: no-store-remote,
max-age=3600
SURROGATE CAPABILITY
Surrogate-Capability: key="ESI/1.0"
Surrogate-Control: content="ESI/1.0"
Surrogate-Capability: varnish="ESI/1.0"
Surrogate-Control: max-age=60, max-
age=86400;varnish, max-age=3600;cdn,
content="ESI/1.0";varnish
HTTP headers that make your website go faster
PERSONAL
DATA
SEPARATE
HTTP REQUEST
AJAX
EDGE-SIDE INCLUDES ESI
<esi:include src="/header" />
ESI
✓ PLACEHOLDER
✓ PARSED BY EDGE CACHE (VARNISH)
✓ OUTPUT IS A COMPOSITION OF BLOCKS
✓ STATE PER BLOCK
✓ TTL PER BLOCK
EDGE Surrogate-Capability: key="ESI/1.0"
Surrogate-Control: content="ESI/1.0"
<esi:include src="/header" />
ORIGIN
Parse ESI placeholders
EDGE
<!DOCTYPE html>
<html>
<body>
<esi:include src="/header" />
<p>Welcome</p>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p>The current time is 21:07:53.</p>
<p>Welcome</p>
</body>
</html>
THIS IS JUST THE TIP OF THE ICEBERG
EVERY
IMPLEMENTATION
HAS ITS OWN
CACHE POLICY
CONFIGURATION
REMEMBER
THIS ONE?
VARNISH CONFIGURATION LANGUAGE
HTTP headers that make your website go faster
HTTPS://VARNISH-SOFTWARE.COM/DEVELOPERS
HTTP headers that make your website go faster
HTTP headers that make your website go faster

More Related Content

PDF
HTTP headers that make your website go faster - devs.gent November 2023
PDF
HTTP headers that will make your website go faster
KEY
Fearless HTTP requests abuse
PDF
Caching in HTTP
PDF
Developing Cacheable PHP Applications - PHP SP 2024
PPTX
Http caching
PDF
HTTP Caching in Web Application
PDF
Developing cacheable backend applications - Appdevcon 2019
HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that will make your website go faster
Fearless HTTP requests abuse
Caching in HTTP
Developing Cacheable PHP Applications - PHP SP 2024
Http caching
HTTP Caching in Web Application
Developing cacheable backend applications - Appdevcon 2019

Similar to HTTP headers that make your website go faster (20)

PDF
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
PDF
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
PDF
From Web Acceleration to Content Delivery with Varnish - Howest Brugge 2024
PDF
Clug 2012 March web server optimisation
PPTX
Cache is King
PDF
API Caching, why your server needs some rest
PPTX
Reverse proxy & web cache with NGINX, HAProxy and Varnish
PDF
Integrated Cache on Netscaler
PPTX
Caching
PPTX
Http caching basics
PPTX
cache concepts and varnish-cache
PPTX
Caching up is hard to do: Improving your Web Services' Performance
PPTX
Advanced Caching Concepts @ Velocity NY 2015
PDF
HTTP cache @ PUG Rome 03-29-2011
PDF
Tips for going fast in a slow world: Michael May at OSCON 2015
PPT
World Wide Web Caching
PDF
Web performance optimization - MercadoLibre
PDF
Saving The World From Guaranteed APOCALYPSE* Using Varnish and Memcached
PDF
JS Fest 2019. Andrew Betts. Headers for hackers
PDF
Web performance mercadolibre - ECI 2013
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
From Web Acceleration to Content Delivery with Varnish - Howest Brugge 2024
Clug 2012 March web server optimisation
Cache is King
API Caching, why your server needs some rest
Reverse proxy & web cache with NGINX, HAProxy and Varnish
Integrated Cache on Netscaler
Caching
Http caching basics
cache concepts and varnish-cache
Caching up is hard to do: Improving your Web Services' Performance
Advanced Caching Concepts @ Velocity NY 2015
HTTP cache @ PUG Rome 03-29-2011
Tips for going fast in a slow world: Michael May at OSCON 2015
World Wide Web Caching
Web performance optimization - MercadoLibre
Saving The World From Guaranteed APOCALYPSE* Using Varnish and Memcached
JS Fest 2019. Andrew Betts. Headers for hackers
Web performance mercadolibre - ECI 2013
Ad

More from Thijs Feryn (20)

PDF
Optimizing Varnish for Magento: Advanced Techniques for Performance and Scala...
PDF
HTTP logging with varnishlog (Brussels PHP 2022)
PDF
The Subtle Art Of Cache Invalidation (FOSSingapore 2024)
PDF
Best practices for caching Plone with Varnish at large scale - PloneConf Bras...
PDF
Varnish caching in Plone - PloneConf Brasilia 2024
PDF
Caching the uncacheable in Varnish - SREday London 2024.pdf
PDF
Varnish Enterprise - when you need the full power of caching
PDF
Accelerate your Kubernetes clusters with Varnish Caching
PDF
10 things that helped me advance my career - PHP UK Conference 2024
PDF
Distributed load testing with K6 - NDC London 2024
PDF
Living on the edge - EBU Horizons 2023
PDF
Distributed Load Testing with k6 - DevOps Barcelona
PDF
Core web vitals meten om je site sneller te maken - Combell Partner Day 2023
PDF
Distributed load testing with k6
PDF
HTTP logging met Varnishlog - PHPWVL 2022
PDF
Taking Laravel to the edge with HTTP caching and Varnish
PDF
Build your own CDN with Varnish - Confoo 2022
PDF
Caching the uncacheable with Varnish - DevDays 2021
PDF
How Cloud addresses the needs of todays internet - Korazon 2018
PDF
Developing cacheable PHP applications - PHPLimburgBE 2018
Optimizing Varnish for Magento: Advanced Techniques for Performance and Scala...
HTTP logging with varnishlog (Brussels PHP 2022)
The Subtle Art Of Cache Invalidation (FOSSingapore 2024)
Best practices for caching Plone with Varnish at large scale - PloneConf Bras...
Varnish caching in Plone - PloneConf Brasilia 2024
Caching the uncacheable in Varnish - SREday London 2024.pdf
Varnish Enterprise - when you need the full power of caching
Accelerate your Kubernetes clusters with Varnish Caching
10 things that helped me advance my career - PHP UK Conference 2024
Distributed load testing with K6 - NDC London 2024
Living on the edge - EBU Horizons 2023
Distributed Load Testing with k6 - DevOps Barcelona
Core web vitals meten om je site sneller te maken - Combell Partner Day 2023
Distributed load testing with k6
HTTP logging met Varnishlog - PHPWVL 2022
Taking Laravel to the edge with HTTP caching and Varnish
Build your own CDN with Varnish - Confoo 2022
Caching the uncacheable with Varnish - DevDays 2021
How Cloud addresses the needs of todays internet - Korazon 2018
Developing cacheable PHP applications - PHPLimburgBE 2018
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Approach and Philosophy of On baking technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
MYSQL Presentation for SQL database connectivity
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
Review of recent advances in non-invasive hemoglobin estimation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
Advanced methodologies resolving dimensionality complications for autism neur...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Approach and Philosophy of On baking technology
MIND Revenue Release Quarter 2 2025 Press Release
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
sap open course for s4hana steps from ECC to s4
MYSQL Presentation for SQL database connectivity

HTTP headers that make your website go faster