{"id":513516,"date":"2025-11-17T11:36:39","date_gmt":"2025-11-17T11:36:39","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=513516"},"modified":"2025-12-03T12:16:22","modified_gmt":"2025-12-03T12:16:22","slug":"implement-collection-cache-in-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/","title":{"rendered":"Implementing Cache for Collection Query Results in Magento 2"},"content":{"rendered":"\n<p>Improving performance is a top priority for any Magento 2 store, especially when handling heavy database queries.<\/p>\n\n\n\n<p> Collections, whether for products, orders, or custom entities, can become expensive to load repeatedly.<\/p>\n\n\n\n<p>One of the most effective ways to improve performance is to <strong>cache the results of collection queries<\/strong>, so Magento doesn\u2019t hit the database every time.<\/p>\n\n\n\n<p>Looking to improve your store\u2019s speed and overall performance? Check out our <a href=\"https:\/\/webkul.com\/magento-speed-optimization-services\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Speed &amp; Optimization services<\/a>.<\/p>\n\n\n\n<p>In this guide, we\u2019ll walk through why caching is important, how Magento handles caching internally, and how you can implement collection-level caching safely and efficiently.<\/p>\n\n\n\n<p>You can check the overview in the video below \u2014<\/p>\n\n\n\n<div class=\"wp-block-wk-block-youtube-video wp-block-wk-block--yt-video components-placeholder\"><div class=\"wk-block--yt-video-frame\"><div class=\"wk-block--yt-video-frame-request\" data-plyr-provider=\"youtube\" data-plyr-embed-id=\"ch1oRrgE17o\"><div class=\"components-placeholder__instructions\">ch1oRrgE17o<\/div><\/div><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><br><strong>Why Cache Collection Queries?<\/strong><\/h2>\n\n\n\n<p>Magento collections often include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Multiple <code>JOIN<\/code> operations<\/li>\n\n\n\n<li>Filters, grouping, or sorting<\/li>\n\n\n\n<li>EAV attribute loading<\/li>\n\n\n\n<li>Large datasets (products, orders, customers)<\/li>\n<\/ul>\n\n\n\n<p>Without caching, these queries run on every request, which:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Increases database load<\/li>\n\n\n\n<li>Slows down page generation<\/li>\n\n\n\n<li>Impacts overall site performance<\/li>\n<\/ul>\n\n\n\n<p>By caching collection results, you reduce repetitive processing and deliver faster responses to users\u2014and to APIs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How Magento Handles Collection Caching<\/strong><\/h2>\n\n\n\n<p>Magento 2 provides a built-in mechanism to cache database fetch operations. This is done using the <code>FetchStrategy<\/code> class.<\/p>\n\n\n\n<p>The default strategy does <strong>not cache<\/strong> data, but Magento includes a ready-to-use caching strategy here:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Magento\\Framework\\Data\\Collection\\Db\\FetchStrategy\\Cache\n<\/pre>\n\n\n\n<p>When enabled, this strategy stores collection results in Magento&#8217;s cache and returns them instantly on subsequent loads.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Enable Cache for a Custom Collection<\/strong><\/h2>\n\n\n\n<p>You can apply collection caching using <code>di.xml<\/code> by specifying the <code>FetchStrategy<\/code> class for your collection.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example: Enable Caching for a Custom Collection<\/strong><\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;type name=\"Vendor\\Module\\Model\\ResourceModel\\Custom\\Collection\"&gt;\n    &lt;arguments&gt;\n        &lt;argument name=\"fetchStrategy\" xsi:type=\"object\"&gt;\n            Magento\\Framework\\Data\\Collection\\Db\\FetchStrategy\\Cache\n        &lt;\/argument&gt;\n    &lt;\/arguments&gt;\n&lt;\/type&gt;\n<\/pre>\n\n\n\n<p>Once added, Magento will automatically start caching the results of this collection. <\/p>\n\n\n\n<p><strong>But what if you want to clear the cached collection data using custom cache tags?<\/strong><\/p>\n\n\n\n<p>By default, Magento stores collection results under the generic <code>COLLECTION_DATA<\/code> tag. If you need to associate your own tags for more granular control, you can do so. <br>Here\u2019s an example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;virtualType name=\"CustomCollectionCacheFetchStrategy\" type=\"Magento\\Framework\\Data\\Collection\\Db\\FetchStrategy\\Cache\"&gt;\n    &lt;arguments&gt;\n        &lt;argument name=\"cacheTags\" xsi:type=\"array\"&gt;\n            &lt;item name=\"custom\" xsi:type=\"string\"&gt;custom_collection&lt;\/item&gt;\n        &lt;\/argument&gt;\n    &lt;\/arguments&gt;\n&lt;\/virtualType&gt;\n&lt;type name=\"Vendor\\Module\\Model\\ResourceModel\\Custom\\Collection\"&gt;\n    &lt;arguments&gt;\n        &lt;argument name=\"fetchStrategy\" xsi:type=\"object\"&gt;CustomCollectionCacheFetchStrategy&lt;\/argument&gt;\n    &lt;\/arguments&gt;\n&lt;\/type&gt;<\/pre>\n\n\n\n<p>After enabling caching for Collection, Magento applies this cache globally. <\/p>\n\n\n\n<p>That means <strong>every part of the system that loads this collection\u2014including UI Components\u2014will automatically use the cached data<\/strong>.<\/p>\n\n\n\n<p>To prevent this, we create a virtual class for caching so only the targeted context uses it, while the UI Component uses the original collection.<\/p>\n\n\n\n<p>Below is an example showing how to enable caching for Collection exclusively within the module by updating <code>di.xml<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;virtualType name=\"CustomCollectionCacheFetchStrategy\" type=\"Magento\\Framework\\Data\\Collection\\Db\\FetchStrategy\\Cache\"&gt;\n    &lt;arguments&gt;\n        &lt;argument name=\"cacheTags\" xsi:type=\"array\"&gt;\n            &lt;item name=\"custom\" xsi:type=\"string\"&gt;custom_collection&lt;\/item&gt;\n        &lt;\/argument&gt;\n    &lt;\/arguments&gt;\n&lt;\/virtualType&gt;\n&lt;virtualType name=\"VirtualCustomCollection\" type=\"Vendor\\Module\\Model\\ResourceModel\\Custom\\Collection\"&gt;\n    &lt;arguments&gt;\n        &lt;argument name=\"fetchStrategy\" xsi:type=\"object\"&gt;CustomCollectionCacheFetchStrategy&lt;\/argument&gt;\n    &lt;\/arguments&gt;\n&lt;\/virtualType&gt;\n&lt;virtualType name=\"VirtualTypeCustomCollectionFactory\" type=\"Vendor\\Module\\Model\\ResourceModel\\Custom\\CollectionFactory\"&gt;\n    &lt;arguments&gt;\n        &lt;argument name=\"instanceName\" xsi:type=\"string\"&gt;VirtualCustomCollection&lt;\/argument&gt;\n    &lt;\/arguments&gt;\n&lt;\/virtualType&gt;\n&lt;type name=\"Vendor\\Module\\Block\\Custom\"&gt;\n    &lt;arguments&gt;\n        &lt;argument name=\"customCollectionFactory\" xsi:type=\"object\"&gt;VirtualTypeCustomCollectionFactory&lt;\/argument&gt;\n    &lt;\/arguments&gt;\n&lt;\/type&gt;<\/pre>\n\n\n\n<p>This way, you can have a context-specific cache for your custom collection. <\/p>\n\n\n\n<p>If you want to create a custom cache tag in Magento 2, please refer to our blog: <br><a href=\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to create a custom cache type in Magento<\/a><\/p>\n\n\n\n<p>Please check the images below for the difference between before and after implementing cache collection.<br>Before:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"1487\" height=\"701\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp\" alt=\"Before Collection Cache\" class=\"wp-image-515214\" style=\"width:1120px\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp 1487w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2-300x141.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2-1200x566.webp 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2-250x118.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2-768x362.webp 768w\" sizes=\"(max-width: 1487px) 100vw, 1487px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>After:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"1541\" height=\"702\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/after-collection-cache2.webp\" alt=\"After Collection Cache\" class=\"wp-image-515116\" style=\"width:1120px\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/after-collection-cache2.webp 1541w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/after-collection-cache2-300x137.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/after-collection-cache2-1200x547.webp 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/after-collection-cache2-250x114.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/after-collection-cache2-768x350.webp 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/after-collection-cache2-1536x700.webp 1536w\" sizes=\"(max-width: 1541px) 100vw, 1541px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Hope this makes the caching workflow easier to implement and adapt to your needs.<br>Happy Coding \ud83d\ude42<\/p>\n\n\n\n<p>You can also explore a wide range of solutions to enhance your Magento 2 store by visiting our <strong><a href=\"https:\/\/store.webkul.com\/Magento-2.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 extensions<\/a><\/strong> page.<\/p>\n\n\n\n<p>For expert guidance or custom feature development, you may <strong><a href=\"https:\/\/webkul.com\/hire-magento-developers\/\" target=\"_blank\" rel=\"noreferrer noopener\">hire our Magento 2 developers<\/a><\/strong> to support your project.<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Improving performance is a top priority for any Magento 2 store, especially when handling heavy database queries. Collections, whether for products, orders, or custom entities, can become expensive to load repeatedly. One of the most effective ways to improve performance is to cache the results of collection queries, so Magento doesn\u2019t hit the database every <a href=\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":451,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121,1],"tags":[],"class_list":["post-513516","post","type-post","status-publish","format-standard","hentry","category-magento-2","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Implementing Cache for Collection Query Results in Magento 2<\/title>\n<meta name=\"description\" content=\"A complete guide to Magento 2 collection caching: enable cache, add custom tags, prevent UI Component caching, and improve store performance.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Implementing Cache for Collection Query Results in Magento 2\" \/>\n<meta property=\"og:description\" content=\"A complete guide to Magento 2 collection caching: enable cache, add custom tags, prevent UI Component caching, and improve store performance.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-17T11:36:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-03T12:16:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp\" \/>\n<meta name=\"author\" content=\"Anupam Rastogi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anupam Rastogi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/\"},\"author\":{\"name\":\"Anupam Rastogi\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/4cad4a620cf2ba97641cde049b05b611\"},\"headline\":\"Implementing Cache for Collection Query Results in Magento 2\",\"datePublished\":\"2025-11-17T11:36:39+00:00\",\"dateModified\":\"2025-12-03T12:16:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/\"},\"wordCount\":496,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp\",\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/\",\"name\":\"Implementing Cache for Collection Query Results in Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp\",\"datePublished\":\"2025-11-17T11:36:39+00:00\",\"dateModified\":\"2025-12-03T12:16:22+00:00\",\"description\":\"A complete guide to Magento 2 collection caching: enable cache, add custom tags, prevent UI Component caching, and improve store performance.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp\",\"width\":1487,\"height\":701,\"caption\":\"Before Collection Cache\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Implementing Cache for Collection Query Results in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/4cad4a620cf2ba97641cde049b05b611\",\"name\":\"Anupam Rastogi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9d600bc915429f53470a78d15d736cc2ec8b59c57b88a97fa55b0cd51124faa7?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9d600bc915429f53470a78d15d736cc2ec8b59c57b88a97fa55b0cd51124faa7?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Anupam Rastogi\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/anupam-rastogi694\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Implementing Cache for Collection Query Results in Magento 2","description":"A complete guide to Magento 2 collection caching: enable cache, add custom tags, prevent UI Component caching, and improve store performance.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/","og_locale":"en_US","og_type":"article","og_title":"Implementing Cache for Collection Query Results in Magento 2","og_description":"A complete guide to Magento 2 collection caching: enable cache, add custom tags, prevent UI Component caching, and improve store performance.","og_url":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2025-11-17T11:36:39+00:00","article_modified_time":"2025-12-03T12:16:22+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp","type":"","width":"","height":""}],"author":"Anupam Rastogi","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Anupam Rastogi","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/"},"author":{"name":"Anupam Rastogi","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/4cad4a620cf2ba97641cde049b05b611"},"headline":"Implementing Cache for Collection Query Results in Magento 2","datePublished":"2025-11-17T11:36:39+00:00","dateModified":"2025-12-03T12:16:22+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/"},"wordCount":496,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp","articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/","url":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/","name":"Implementing Cache for Collection Query Results in Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp","datePublished":"2025-11-17T11:36:39+00:00","dateModified":"2025-12-03T12:16:22+00:00","description":"A complete guide to Magento 2 collection caching: enable cache, add custom tags, prevent UI Component caching, and improve store performance.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2025\/11\/before-collection-cache2.webp","width":1487,"height":701,"caption":"Before Collection Cache"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/implement-collection-cache-in-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Implementing Cache for Collection Query Results in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/4cad4a620cf2ba97641cde049b05b611","name":"Anupam Rastogi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9d600bc915429f53470a78d15d736cc2ec8b59c57b88a97fa55b0cd51124faa7?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9d600bc915429f53470a78d15d736cc2ec8b59c57b88a97fa55b0cd51124faa7?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Anupam Rastogi"},"url":"https:\/\/webkul.com\/blog\/author\/anupam-rastogi694\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/513516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/451"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=513516"}],"version-history":[{"count":32,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/513516\/revisions"}],"predecessor-version":[{"id":515215,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/513516\/revisions\/515215"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=513516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=513516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=513516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}