SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Dernier

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+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
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 

Dernier (20)

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
+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...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
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 ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
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...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
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-...
 

En vedette

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
ThinkNow
 
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
Kurio // The Social Media Age(ncy)
 

En vedette (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

Notes de l'éditeur

  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