SlideShare ist ein Scribd-Unternehmen logo
1 von 35
The power of ESI and 
HTTP Cache for 
performant page delivery 
Ivo Lukač @ ZgPHP Conference 2014, Zagreb
www.netgenlabs.com 
Warning! 
• Not so much code in the slides 
• This is more about using right tools for 
the job and integrating those tools
www.netgenlabs.com 
Netgen 
• Web technology company, established 2002 
• Focused on middle and big size web projects based on eZ 
Publish CMS and Symfony 
• eZ Business partner from 2007 
• Working for eZ Systems on core eZ ver 5 stuff from 2012 
• Very active in the community 
• Organised 3rd in a row eZ/PHP Summer Camp, more than 
90 people from across EU this September in Rovinj
www.netgenlabs.com
www.netgenlabs.com 
The problem 
• Middle and big size web sites need to be cached 
on various levels as much as possible 
• But the specific cache needs to be invalidated 
when there is some change in the content 
• So simple “cache everything with TTL in days“ is 
not an option if there are frequent content 
changes on sites that are also cross linked a lot 
(e.g. News, Media, Portals, etc)
www.netgenlabs.com 
News, Media, etc
www.netgenlabs.com 
Agenda 
• How to cache content pages and invalidate when necessary 
• How to cache parts of content pages and invalidate when 
necessary 
Focus on optimal cache strategy: 
invalidate only when there is a change in 
content 
* We are not covering caching of static assets like css, javascript and 
images. These are usually cached with long TTL and versioned with 
hash in the url
www.netgenlabs.com 
Part 1 
• How to cache content pages and invalidate 
when necessary: 
- use a powerful CMS 
- with a good framework 
- and a fast reverse proxy 
- which all support W3C standards :)
www.netgenlabs.com 
eZ Publish CMS 
• Powerful enterprise open source CMS 
• Developed and supported by eZ Systems, Norway 
• Symfony full stack from eZ version 5.0 
• Latest versions: 5.3 EE and 2014.07 CE
Content caching in eZ 
• eZ Publish has an integrated content caching 
system that figures out when to invalidate what 
page cache: Smart View Cache 
• In version 4 cache was stored to files locally 
• In version 5 it uses HTTP Cache implementation 
from Symfony to integrate reverse proxies for 
content caching 
www.netgenlabs.com
Smart View Cache rules 
www.netgenlabs.com 
example 
[folder] 
DependentClassIdentifier[]=frontpage 
ClearCacheMethod[]=object 
ClearCacheMethod[]=relating 
[article] 
DependentClassIdentifier[]=folder 
DependentClassIdentifier[]=frontpage 
ClearCacheMethod[]=object 
ClearCacheMethod[]=relating
www.netgenlabs.com 
Symfony 
• Powerful and modern PHP framework 
• Separated in many components 
• Big community 
• Excellent documentation 
• Supported by Sensio Labs 
• Latest version: 2.5.5
www.netgenlabs.com 
HTTP Cache 
• Part of RFC 2616 (HTTP/1.1) 
• 2 models of cache handling: 
• Expiration: “Cache-Control”, “Expires” 
• Validation: “ETag", “Last-modified” 
(not implemented with eZ 5 yet as it doesn’t 
behave very well in multiuser scenario)
www.netgenlabs.com 
Expiration with 
Cache-Control 
• setting headers to public instead of private 
to cache pages in reverse proxy (private is 
default in Symfony) 
• setting max-age header (or specifically s-maxage) 
to some bigger number (days or 
even more)
www.netgenlabs.com 
Cache miss 
credits to http://tomayko.com/writings/things-caches-do
www.netgenlabs.com 
Cache hit 
credits to http://tomayko.com/writings/things-caches-do
In Symfony? 
use SymfonyComponentHttpFoundationResponse; 
$response = new Response(); 
// mark the response as either public or private 
$response->setPublic(); 
$response->setPrivate(); 
www.netgenlabs.com 
// set the private or shared max age 
$response->setMaxAge(600); 
$response->setSharedMaxAge(600);
Finally some code! 
www.netgenlabs.com
www.netgenlabs.com 
But what about 
invalidation? 
• as the Etag is not implemented yet a different 
mechanism is used to invalidate cache 
• custom header X-Location-Id: 123 is set to mark the 
page with location id 123 
• eZ content caching mechanism calls HTTP 
command PURGE against the reverse proxy when 
its necessary to invalidate a specific cache
www.netgenlabs.com 
How eZ does it? 
# stock ViewController::viewLocation() 
$response->setPublic(); 
if ( $this->getParameter( 'content.ttl_cache' ) === true ) 
{ 
$response->setSharedMaxAge( $this->getParameter( 'content.default_ttl' )); 
} 
if ( $request->headers->has( 'X-User-Hash' ) ) 
{ 
$response->setVary( 'X-User-Hash' ); 
} 
$response->headers->set( 'X-Location-Id', $locationId );
Reverse proxy becomes 
www.netgenlabs.com 
very important 
• Reverse proxy AKA web accelerator or 
gateway cache 
• preferred with Symfony and eZ Publish: 
Varnish Cache
www.netgenlabs.com 
Varnish Cache 
• HTTP reverse proxy (web accelerator) 
• Performant and configurable 
• Supports most important parts of ESI 
• Supported by Varnish Software 
• Latest version: 4.0
Varnish Cache setup 
www.netgenlabs.com 
• we need to support PURGE call 
sub vcl_recv { 
if (req.request == "PURGE") { return(lookup); } 
} 
sub vcl_hit { 
if (req.request == "PURGE") { 
set obj.ttl = 0s; 
error 200 "Purged"; 
} 
} 
sub vcl_miss { 
if (req.request == "PURGE") { error 404 "Not purged”; } 
}
www.netgenlabs.com 
Part 2 
• How to cache parts of content pages and 
invalidate when necessary: 
- use a powerful CMS 
- with a good framework 
- and a fast reverse proxy 
- which all support ESI :)
Block caching in eZ 
• Repeatable parts of a page need special 
attention (header, menus, footer, sidebars, etc) 
• In eZ version 4 cache blocks were stored to files 
locally 
• In eZ version 5 it uses the same HTTP Cache 
principles but with ESI powered fragments 
www.netgenlabs.com
Fragments in Symfony 
• Enable sub requests to be callable via URI 
• Trust only certain IPs (reverse proxies) to call it 
• Could be used directly from web clients (from javascript with 
www.netgenlabs.com 
hinclude.js) but then the call must be signed 
# app/config/config.yml 
framework: 
esi: { enabled: true } 
fragments: { path: /_fragment } 
trusted_proxies: [127.0.0.1, 10.0.0.0/8]
Edge Side Includes 
• Markup protocol for proxies to cache partial pages 
• Specified by Akamai 
• Implemented by many proxies, including Varnish 
• The most simple implementation: 
<esi:include src=“http://foo.bar/1.html"/> 
www.netgenlabs.com
Include ESI block 
www.netgenlabs.com 
• render sub request as ESI in Symfony (will 
generate ESI markup if stated in the request): 
{{ render_esi( controller( 
'aController:someAction', 
{ 'foo': 'bar' } 
)) 
}}
Cache control on block 
www.netgenlabs.com 
level 
• as each block is a sub request we can set different 
headers (private or public, ttl, etc.) 
• this can be per block type (from settings) or even per 
block (parameter set by editor) 
• when it makes sense X-Location-Id header is set 
automatically so the cache can be invalidated
Varnish Cache setup 
• when Varnish request a page from the web server it needs to tell 
that it wants ESI markup instead of rendered HTML 
www.netgenlabs.com 
sub vcl_recv { 
// Add a header to announce ESI support. 
set req.http.Surrogate-Capability = "abc=ESI/1.0"; 
}
www.netgenlabs.com 
Result? 
• common blocks have long TTL and get rarely 
executed on backend 
• they are mostly just embedded from cache when 
the reverse proxy builds the page with ESI tags 
• possible different cache strategies for different 
pages, zones and blocks across the whole site
www.netgenlabs.com 
Caution 
• A rule of thumb is not to have more than 10 sub 
requests in one page render 
• As there might be lot of blocks on the page we 
create zones of blocks that are rendered as sub 
request with a small TTL (that way we spread the 
sub requests over more page renderings)
Achieved scenario 
• When an editor creates some new content 
(article) in a news section (folder), CMS will 
automatically purge the cache of the folder and 
the latest news block on the frontage so that 
the new article shows up instantly on both 
pages without touching other cache 
www.netgenlabs.com
www.netgenlabs.com
Questions now or later 
ivo@netgen.hr 
ilukac.com/twitter 
ilukac.com/facebook 
ilukac.com/gplus 
ilukac.com/linkedin

Weitere ähnliche Inhalte

Kürzlich hochgeladen

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 

Kürzlich hochgeladen (20)

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

The power of ESI and HTTP Cache for performant page delivery

  • 1. The power of ESI and HTTP Cache for performant page delivery Ivo Lukač @ ZgPHP Conference 2014, Zagreb
  • 2. www.netgenlabs.com Warning! • Not so much code in the slides • This is more about using right tools for the job and integrating those tools
  • 3. www.netgenlabs.com Netgen • Web technology company, established 2002 • Focused on middle and big size web projects based on eZ Publish CMS and Symfony • eZ Business partner from 2007 • Working for eZ Systems on core eZ ver 5 stuff from 2012 • Very active in the community • Organised 3rd in a row eZ/PHP Summer Camp, more than 90 people from across EU this September in Rovinj
  • 5. www.netgenlabs.com The problem • Middle and big size web sites need to be cached on various levels as much as possible • But the specific cache needs to be invalidated when there is some change in the content • So simple “cache everything with TTL in days“ is not an option if there are frequent content changes on sites that are also cross linked a lot (e.g. News, Media, Portals, etc)
  • 7. www.netgenlabs.com Agenda • How to cache content pages and invalidate when necessary • How to cache parts of content pages and invalidate when necessary Focus on optimal cache strategy: invalidate only when there is a change in content * We are not covering caching of static assets like css, javascript and images. These are usually cached with long TTL and versioned with hash in the url
  • 8. www.netgenlabs.com Part 1 • How to cache content pages and invalidate when necessary: - use a powerful CMS - with a good framework - and a fast reverse proxy - which all support W3C standards :)
  • 9. www.netgenlabs.com eZ Publish CMS • Powerful enterprise open source CMS • Developed and supported by eZ Systems, Norway • Symfony full stack from eZ version 5.0 • Latest versions: 5.3 EE and 2014.07 CE
  • 10. Content caching in eZ • eZ Publish has an integrated content caching system that figures out when to invalidate what page cache: Smart View Cache • In version 4 cache was stored to files locally • In version 5 it uses HTTP Cache implementation from Symfony to integrate reverse proxies for content caching www.netgenlabs.com
  • 11. Smart View Cache rules www.netgenlabs.com example [folder] DependentClassIdentifier[]=frontpage ClearCacheMethod[]=object ClearCacheMethod[]=relating [article] DependentClassIdentifier[]=folder DependentClassIdentifier[]=frontpage ClearCacheMethod[]=object ClearCacheMethod[]=relating
  • 12. www.netgenlabs.com Symfony • Powerful and modern PHP framework • Separated in many components • Big community • Excellent documentation • Supported by Sensio Labs • Latest version: 2.5.5
  • 13. www.netgenlabs.com HTTP Cache • Part of RFC 2616 (HTTP/1.1) • 2 models of cache handling: • Expiration: “Cache-Control”, “Expires” • Validation: “ETag", “Last-modified” (not implemented with eZ 5 yet as it doesn’t behave very well in multiuser scenario)
  • 14. www.netgenlabs.com Expiration with Cache-Control • setting headers to public instead of private to cache pages in reverse proxy (private is default in Symfony) • setting max-age header (or specifically s-maxage) to some bigger number (days or even more)
  • 15. www.netgenlabs.com Cache miss credits to http://tomayko.com/writings/things-caches-do
  • 16. www.netgenlabs.com Cache hit credits to http://tomayko.com/writings/things-caches-do
  • 17. In Symfony? use SymfonyComponentHttpFoundationResponse; $response = new Response(); // mark the response as either public or private $response->setPublic(); $response->setPrivate(); www.netgenlabs.com // set the private or shared max age $response->setMaxAge(600); $response->setSharedMaxAge(600);
  • 18. Finally some code! www.netgenlabs.com
  • 19. www.netgenlabs.com But what about invalidation? • as the Etag is not implemented yet a different mechanism is used to invalidate cache • custom header X-Location-Id: 123 is set to mark the page with location id 123 • eZ content caching mechanism calls HTTP command PURGE against the reverse proxy when its necessary to invalidate a specific cache
  • 20. www.netgenlabs.com How eZ does it? # stock ViewController::viewLocation() $response->setPublic(); if ( $this->getParameter( 'content.ttl_cache' ) === true ) { $response->setSharedMaxAge( $this->getParameter( 'content.default_ttl' )); } if ( $request->headers->has( 'X-User-Hash' ) ) { $response->setVary( 'X-User-Hash' ); } $response->headers->set( 'X-Location-Id', $locationId );
  • 21. Reverse proxy becomes www.netgenlabs.com very important • Reverse proxy AKA web accelerator or gateway cache • preferred with Symfony and eZ Publish: Varnish Cache
  • 22. www.netgenlabs.com Varnish Cache • HTTP reverse proxy (web accelerator) • Performant and configurable • Supports most important parts of ESI • Supported by Varnish Software • Latest version: 4.0
  • 23. Varnish Cache setup www.netgenlabs.com • we need to support PURGE call sub vcl_recv { if (req.request == "PURGE") { return(lookup); } } sub vcl_hit { if (req.request == "PURGE") { set obj.ttl = 0s; error 200 "Purged"; } } sub vcl_miss { if (req.request == "PURGE") { error 404 "Not purged”; } }
  • 24. www.netgenlabs.com Part 2 • How to cache parts of content pages and invalidate when necessary: - use a powerful CMS - with a good framework - and a fast reverse proxy - which all support ESI :)
  • 25. Block caching in eZ • Repeatable parts of a page need special attention (header, menus, footer, sidebars, etc) • In eZ version 4 cache blocks were stored to files locally • In eZ version 5 it uses the same HTTP Cache principles but with ESI powered fragments www.netgenlabs.com
  • 26. Fragments in Symfony • Enable sub requests to be callable via URI • Trust only certain IPs (reverse proxies) to call it • Could be used directly from web clients (from javascript with www.netgenlabs.com hinclude.js) but then the call must be signed # app/config/config.yml framework: esi: { enabled: true } fragments: { path: /_fragment } trusted_proxies: [127.0.0.1, 10.0.0.0/8]
  • 27. Edge Side Includes • Markup protocol for proxies to cache partial pages • Specified by Akamai • Implemented by many proxies, including Varnish • The most simple implementation: <esi:include src=“http://foo.bar/1.html"/> www.netgenlabs.com
  • 28. Include ESI block www.netgenlabs.com • render sub request as ESI in Symfony (will generate ESI markup if stated in the request): {{ render_esi( controller( 'aController:someAction', { 'foo': 'bar' } )) }}
  • 29. Cache control on block www.netgenlabs.com level • as each block is a sub request we can set different headers (private or public, ttl, etc.) • this can be per block type (from settings) or even per block (parameter set by editor) • when it makes sense X-Location-Id header is set automatically so the cache can be invalidated
  • 30. Varnish Cache setup • when Varnish request a page from the web server it needs to tell that it wants ESI markup instead of rendered HTML www.netgenlabs.com sub vcl_recv { // Add a header to announce ESI support. set req.http.Surrogate-Capability = "abc=ESI/1.0"; }
  • 31. www.netgenlabs.com Result? • common blocks have long TTL and get rarely executed on backend • they are mostly just embedded from cache when the reverse proxy builds the page with ESI tags • possible different cache strategies for different pages, zones and blocks across the whole site
  • 32. www.netgenlabs.com Caution • A rule of thumb is not to have more than 10 sub requests in one page render • As there might be lot of blocks on the page we create zones of blocks that are rendered as sub request with a small TTL (that way we spread the sub requests over more page renderings)
  • 33. Achieved scenario • When an editor creates some new content (article) in a news section (folder), CMS will automatically purge the cache of the folder and the latest news block on the frontage so that the new article shows up instantly on both pages without touching other cache www.netgenlabs.com
  • 35. Questions now or later ivo@netgen.hr ilukac.com/twitter ilukac.com/facebook ilukac.com/gplus ilukac.com/linkedin

Hinweis der Redaktion

  1. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  2. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  3. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  4. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  5. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  6. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  7. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  8. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  9. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  10. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  11. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  12. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  13. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  14. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  15. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  16. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  17. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  18. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  19. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  20. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  21. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  22. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  23. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  24. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  25. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  26. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  27. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  28. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  29. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  30. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  31. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  32. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija
  33. ne možemo u potpunosti usmjeriti/kontrolirati ponašanje korisnika ali možemo utjecati i usmjeravati ga u određenom smjeru: svrha UX dizajna je određivanje uvjeta unutar kojih se iskustvo odvija