狠狠撸

狠狠撸Share a Scribd company logo
CacheTagsBundle
by Marcin Chy?ek
Edge Side Includes (ESI)
BackendVarnish
WWW
article 1
article 2
article 3
article 4
Request content
Response content
Request/Response
content
ESI + CacheTagsBundle
BackendVarnish
WWW
article 1 (tag: tag_1)
article 2 (tag: tag_2)
article 3 (tag: tag_3)
article 4 (tag: tag_4)
Request content
Response content
Request/Response
content
What is CacheTagsBundle?
What is CacheTagsBundle?
● Tagging Response
What is CacheTagsBundle?
● Tagging Response
● Simple annotation configuration
What is CacheTagsBundle?
● Tagging Response
● Simple annotation configuration
● Cache Invalidation
How to Use CacheTagsBundle
● Plain cache tag
How to Use CacheTagsBundle
● Plain cache tag
● Request attribute tag
How to Use CacheTagsBundle
● Plain cache tag
Add annotation @CacheTagPlain to controller
use lbarulskiCacheTagsBundleAnnotationCacheTagPlain;
/**
* @CacheTagPlain("article_name")
**/
public function articleAction(Request $request)
{
}
How to Use CacheTagsBundle
● Plain cache tag
Prepare response
$response = new Response('...');
$response->setPublic();
$response->setTtl(3600);
How to Use CacheTagsBundle
● Request attribute tag
Implements TagInterface in model
use lbarulskiCacheTagsBundleTagTagInterface;
class Article implements TagInterface
{
public function getTag()
{
return 'article_'.$this->getId();
}
}
How to Use CacheTagsBundle
● Plain cache tag
Add annotation @CacheTagRequestAttribute to controller
use lbarulskiCacheTagsBundleAnnotationCacheTagRequestAttribute;
/**
* @ParamConverter("article")
* @CacheTagRequestAttribute("article")
**/
public function articleAction(Article $article)
{
}
How to Use CacheTagsBundle
● View Template: use esi controller
{{ render_esi(controller('MainBundle:Article:article', { article:
article.id })}}
How to Invalidate CacheTagsBundle
● Invalidate cache tags console
$ ./app/console cache_tags:invalidate tag-name
How to Invalidate CacheTagsBundle
● Invalidate cache tags in controller
use lbarulskiCacheTagsBundleTagPlain;
public function updateArticleAction(Article $article)
{
$tag = 'article_name';
$this->get('cache_tags.invalidator')->invalidate(new Plain($tag));
}
Link
● https://github.com/lbarulski/CacheTagsBundle
● https://www.varnish-cache.org/
marcin@chylek.pl
THANK YOU

More Related Content

Similar to CacheTagsBundle (6)

JS Lab`16. Владимир Воевидка: "Как работает браузер"
JS Lab`16. Владимир Воевидка: "Как работает браузер"JS Lab`16. Владимир Воевидка: "Как работает браузер"
JS Lab`16. Владимир Воевидка: "Как работает браузер"
GeeksLab Odessa
?
How Browser Works?
How Browser Works?How Browser Works?
How Browser Works?
Vova Voyevidka
?
Page Fragments как развитие идеи Page Object паттерна
Page Fragments как развитие идеи Page Object паттернаPage Fragments как развитие идеи Page Object паттерна
Page Fragments как развитие идеи Page Object паттерна
Start IT training center
?
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
Saajan Maharjan
?
JSTL.pptx
JSTL.pptxJSTL.pptx
JSTL.pptx
SPAMVEDANT
?
The underappreciated power of content invalidation
The underappreciated power of content invalidationThe underappreciated power of content invalidation
The underappreciated power of content invalidation
Jakub Wadolowski
?
JS Lab`16. Владимир Воевидка: "Как работает браузер"
JS Lab`16. Владимир Воевидка: "Как работает браузер"JS Lab`16. Владимир Воевидка: "Как работает браузер"
JS Lab`16. Владимир Воевидка: "Как работает браузер"
GeeksLab Odessa
?
Page Fragments как развитие идеи Page Object паттерна
Page Fragments как развитие идеи Page Object паттернаPage Fragments как развитие идеи Page Object паттерна
Page Fragments как развитие идеи Page Object паттерна
Start IT training center
?
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
Saajan Maharjan
?
The underappreciated power of content invalidation
The underappreciated power of content invalidationThe underappreciated power of content invalidation
The underappreciated power of content invalidation
Jakub Wadolowski
?

Recently uploaded (20)

phase_4_presentation[1] - Read-Only.pptx Iot
phase_4_presentation[1]  -  Read-Only.pptx Iotphase_4_presentation[1]  -  Read-Only.pptx Iot
phase_4_presentation[1] - Read-Only.pptx Iot
harshithamandya49
?
IPv6 - Global and Malaysia's Perspectives
IPv6 - Global and Malaysia's PerspectivesIPv6 - Global and Malaysia's Perspectives
IPv6 - Global and Malaysia's Perspectives
APNIC
?
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
taqyed
?
QasyndaAIFinalVersionPresentationStartup
QasyndaAIFinalVersionPresentationStartupQasyndaAIFinalVersionPresentationStartup
QasyndaAIFinalVersionPresentationStartup
AidarIsakhanov
?
Choking_Death_Statistics_2025_Presentation.pptx
Choking_Death_Statistics_2025_Presentation.pptxChoking_Death_Statistics_2025_Presentation.pptx
Choking_Death_Statistics_2025_Presentation.pptx
Joseph897315
?
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdfKeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
sabranghindi
?
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
taqyed
?
IDM Crack 2025 Internet Download Manger Patch
IDM Crack 2025 Internet Download Manger PatchIDM Crack 2025 Internet Download Manger Patch
IDM Crack 2025 Internet Download Manger Patch
wistrendugftr
?
complete On-Page SEO Best Practices guide
complete On-Page SEO Best Practices guidecomplete On-Page SEO Best Practices guide
complete On-Page SEO Best Practices guide
Rana Hassan
?
Importance of understanding buyer behaviors.pptx
Importance of understanding buyer behaviors.pptxImportance of understanding buyer behaviors.pptx
Importance of understanding buyer behaviors.pptx
ankitregmi20580419
?
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteBusiness
?
HITRUST Overview and AI Assessments Webinar.pptx
HITRUST Overview and AI Assessments Webinar.pptxHITRUST Overview and AI Assessments Webinar.pptx
HITRUST Overview and AI Assessments Webinar.pptx
AmyPoblete3
?
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
taqyed
?
Advantages of Outsourcing IT Security Solutions
Advantages of Outsourcing IT Security SolutionsAdvantages of Outsourcing IT Security Solutions
Advantages of Outsourcing IT Security Solutions
Dalin Owen
?
cyber hacking and cyber fraud by internet online money
cyber hacking and cyber fraud by internet online moneycyber hacking and cyber fraud by internet online money
cyber hacking and cyber fraud by internet online money
VEENAKSHI PATHAK
?
A Teaching Guide for Those interested in teaching monkey beach
A Teaching Guide for Those interested in teaching monkey beachA Teaching Guide for Those interested in teaching monkey beach
A Teaching Guide for Those interested in teaching monkey beach
sethiserena
?
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
IJCNCJournal
?
Mastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Mastering FortiWeb: An Extensive Admin Guide for Secure DeploymentsMastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Mastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Atakan ATAK
?
2a Solving Equations Bar Method.pkdkdmptx
2a Solving Equations Bar Method.pkdkdmptx2a Solving Equations Bar Method.pkdkdmptx
2a Solving Equations Bar Method.pkdkdmptx
alvinlibre
?
Antorik Q Final.pptx999999999999999999999
Antorik Q Final.pptx999999999999999999999Antorik Q Final.pptx999999999999999999999
Antorik Q Final.pptx999999999999999999999
PrayasChatterjee1
?
phase_4_presentation[1] - Read-Only.pptx Iot
phase_4_presentation[1]  -  Read-Only.pptx Iotphase_4_presentation[1]  -  Read-Only.pptx Iot
phase_4_presentation[1] - Read-Only.pptx Iot
harshithamandya49
?
IPv6 - Global and Malaysia's Perspectives
IPv6 - Global and Malaysia's PerspectivesIPv6 - Global and Malaysia's Perspectives
IPv6 - Global and Malaysia's Perspectives
APNIC
?
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
taqyed
?
QasyndaAIFinalVersionPresentationStartup
QasyndaAIFinalVersionPresentationStartupQasyndaAIFinalVersionPresentationStartup
QasyndaAIFinalVersionPresentationStartup
AidarIsakhanov
?
Choking_Death_Statistics_2025_Presentation.pptx
Choking_Death_Statistics_2025_Presentation.pptxChoking_Death_Statistics_2025_Presentation.pptx
Choking_Death_Statistics_2025_Presentation.pptx
Joseph897315
?
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdfKeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
sabranghindi
?
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
taqyed
?
IDM Crack 2025 Internet Download Manger Patch
IDM Crack 2025 Internet Download Manger PatchIDM Crack 2025 Internet Download Manger Patch
IDM Crack 2025 Internet Download Manger Patch
wistrendugftr
?
complete On-Page SEO Best Practices guide
complete On-Page SEO Best Practices guidecomplete On-Page SEO Best Practices guide
complete On-Page SEO Best Practices guide
Rana Hassan
?
Importance of understanding buyer behaviors.pptx
Importance of understanding buyer behaviors.pptxImportance of understanding buyer behaviors.pptx
Importance of understanding buyer behaviors.pptx
ankitregmi20580419
?
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteBusiness
?
HITRUST Overview and AI Assessments Webinar.pptx
HITRUST Overview and AI Assessments Webinar.pptxHITRUST Overview and AI Assessments Webinar.pptx
HITRUST Overview and AI Assessments Webinar.pptx
AmyPoblete3
?
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
taqyed
?
Advantages of Outsourcing IT Security Solutions
Advantages of Outsourcing IT Security SolutionsAdvantages of Outsourcing IT Security Solutions
Advantages of Outsourcing IT Security Solutions
Dalin Owen
?
cyber hacking and cyber fraud by internet online money
cyber hacking and cyber fraud by internet online moneycyber hacking and cyber fraud by internet online money
cyber hacking and cyber fraud by internet online money
VEENAKSHI PATHAK
?
A Teaching Guide for Those interested in teaching monkey beach
A Teaching Guide for Those interested in teaching monkey beachA Teaching Guide for Those interested in teaching monkey beach
A Teaching Guide for Those interested in teaching monkey beach
sethiserena
?
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
IJCNCJournal
?
Mastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Mastering FortiWeb: An Extensive Admin Guide for Secure DeploymentsMastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Mastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Atakan ATAK
?
2a Solving Equations Bar Method.pkdkdmptx
2a Solving Equations Bar Method.pkdkdmptx2a Solving Equations Bar Method.pkdkdmptx
2a Solving Equations Bar Method.pkdkdmptx
alvinlibre
?
Antorik Q Final.pptx999999999999999999999
Antorik Q Final.pptx999999999999999999999Antorik Q Final.pptx999999999999999999999
Antorik Q Final.pptx999999999999999999999
PrayasChatterjee1
?

CacheTagsBundle

  • 2. Edge Side Includes (ESI) BackendVarnish WWW article 1 article 2 article 3 article 4 Request content Response content Request/Response content
  • 3. ESI + CacheTagsBundle BackendVarnish WWW article 1 (tag: tag_1) article 2 (tag: tag_2) article 3 (tag: tag_3) article 4 (tag: tag_4) Request content Response content Request/Response content
  • 5. What is CacheTagsBundle? ● Tagging Response
  • 6. What is CacheTagsBundle? ● Tagging Response ● Simple annotation configuration
  • 7. What is CacheTagsBundle? ● Tagging Response ● Simple annotation configuration ● Cache Invalidation
  • 8. How to Use CacheTagsBundle ● Plain cache tag
  • 9. How to Use CacheTagsBundle ● Plain cache tag ● Request attribute tag
  • 10. How to Use CacheTagsBundle ● Plain cache tag Add annotation @CacheTagPlain to controller use lbarulskiCacheTagsBundleAnnotationCacheTagPlain; /** * @CacheTagPlain("article_name") **/ public function articleAction(Request $request) { }
  • 11. How to Use CacheTagsBundle ● Plain cache tag Prepare response $response = new Response('...'); $response->setPublic(); $response->setTtl(3600);
  • 12. How to Use CacheTagsBundle ● Request attribute tag Implements TagInterface in model use lbarulskiCacheTagsBundleTagTagInterface; class Article implements TagInterface { public function getTag() { return 'article_'.$this->getId(); } }
  • 13. How to Use CacheTagsBundle ● Plain cache tag Add annotation @CacheTagRequestAttribute to controller use lbarulskiCacheTagsBundleAnnotationCacheTagRequestAttribute; /** * @ParamConverter("article") * @CacheTagRequestAttribute("article") **/ public function articleAction(Article $article) { }
  • 14. How to Use CacheTagsBundle ● View Template: use esi controller {{ render_esi(controller('MainBundle:Article:article', { article: article.id })}}
  • 15. How to Invalidate CacheTagsBundle ● Invalidate cache tags console $ ./app/console cache_tags:invalidate tag-name
  • 16. How to Invalidate CacheTagsBundle ● Invalidate cache tags in controller use lbarulskiCacheTagsBundleTagPlain; public function updateArticleAction(Article $article) { $tag = 'article_name'; $this->get('cache_tags.invalidator')->invalidate(new Plain($tag)); }