{"id":377684,"date":"2023-04-20T17:25:56","date_gmt":"2023-04-20T17:25:56","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=377684"},"modified":"2026-02-13T11:24:04","modified_gmt":"2026-02-13T11:24:04","slug":"how-to-create-a-custom-cache-type-in-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/","title":{"rendered":"How to create a Custom Cache type in Magento2"},"content":{"rendered":"\n<p>Discover the step-by-step process to build a custom <a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-admin\/systems\/tools\/cache-management\">Magento 2 cache<\/a> type, including all important configuration and implementation details<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Here is a brief summary of the steps involved:<\/strong><\/h2>\n\n\n\n<p>Creating a new module named &#8220;CustomCache&#8221;, the module directory is app\/code\/Webkul\/CustomCache.<\/p>\n\n\n\n<p>Now create a new directory called &#8220;etc&#8221; inside your module directory and create &#8220;cache.xml&#8221; file at app\/code\/Webkul\/CustomCache\/etc\/ with the below code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;!-- \n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_CustomCache\n * @author    Webkul Software Private Limited\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n --&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Cache\/etc\/cache.xsd&quot;&gt;\n    &lt;type name=&quot;webkulcustomcache&quot; translate=&quot;label,description&quot; instance=&quot;Webkul\\CustomCache\\Model\\Cache\\Type&quot;&gt;\n        &lt;label&gt;Webkul Custom Cache&lt;\/label&gt;\n        &lt;description&gt;Webkul Custom Cache Description.&lt;\/description&gt;\n    &lt;\/type&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p>In the cache.xml file, define your custom cache type.<\/p>\n\n\n\n<p>Now, create &#8220;Type.php&#8221; in the directory Webkul\/CustomCache\/Model\/Cache\/ with the below code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_CustomCache\n * @author    Webkul Software Private Limited\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\nnamespace Webkul\\CustomCache\\Model\\Cache;\n\nclass Type extends \\Magento\\Framework\\Cache\\Frontend\\Decorator\\TagScope\n{\n    \/**\n     * Type Code for Cache. It should be unique\n     *\/\n    const TYPE_IDENTIFIER = &#039;webkulcustomcache&#039;;\n\n    \/**\n     * Tag of Cache\n     *\/\n    const CACHE_TAG = &#039;WEBKULCUSTOMCACHE&#039;;\n\n    \/**\n     * @param \\Magento\\Framework\\App\\Cache\\Type\\FrontendPool $cacheFrontendPool\n     *\/\n    public function __construct(    \n        \\Magento\\Framework\\App\\Cache\\Type\\FrontendPool $cacheFrontendPool\n    ){\n        parent::__construct(    \n            $cacheFrontendPool-&gt;get(self::TYPE_IDENTIFIER), \n            self::CACHE_TAG\n        );\n    }\n}<\/pre>\n\n\n\n<p>After registering the module by upgrade command &#8220;<strong>php bin\/magento setup:upgrade<\/strong>&#8220;,<\/p>\n\n\n\n<p> after that when you go to setting System ==> Cache Management in the admin panel, there you will see your newly created cache type a new entry<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"583\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-1200x583.png\" alt=\"customCacheType\" class=\"wp-image-377702\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-1200x583.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-300x146.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-250x122.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-768x373.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType.png 1290w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Make sure to <strong>select and enable the newly added Cache<\/strong> from the mass actions dropdown and click <strong>Submit<\/strong> so that the cache becomes active.<\/p>\n\n\n\n<p>Use your new cache type in your Magento 2 store. You can do this by storing the data in the custom cache type and also retrieving it later from a custom cache type.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">To store serialized data in a custom cache, follow these steps:<\/h3>\n\n\n\n<h5 class=\"wp-block-heading\">Pass the argument to the constructor Magento\\Framework\\Cache\\FrontendInterface $cache of a required class (Repository, Model, Block, etc).<\/h5>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_CustomCache\n * @author    Webkul Software Private Limited\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\nnamespace Webkul\\CustomCache\\Model;\n\nuse Magento\\Framework\\Cache\\FrontendInterface;\nuse Magento\\Framework\\Serialize\\SerializerInterface;\n\nclass OperateCustomCache\n{\n    \/**\n     * @param CacheInterface $cache\n    * @param SerializerInterface $serializer\n    *\/\n    public function __construct(    \n        CacheInterface $cache, \n        SerializerInterface $serializer\n    ){\n        $this-&gt;cache = $cache;\n        $this-&gt;serializer = $serializer;\n    }\n\n    public function saveCache() {\n        $cacheKey  = \\Webkul\\CustomCache\\Model\\Cache\\Type::TYPE_IDENTIFIER;\n        $cacheTag  = \\Webkul\\CustomCache\\Model\\Cache\\Type::CACHE_TAG;\n        \n        $time = date(&#039;Y-m-d H:i:s&#039;);\n        $cacheData = &#091;\n           &#039;name&#039; =&gt; &#039;Webkul&#039;,\n           &#039;type&#039; =&gt; &#039;Custom Cache&#039;,\n           &#039;description&#039; =&gt; &#039;This is custom cache created by Webkul&#039;,\n           &#039;created_at&#039; =&gt; $time\n        ];\n        $storeData = $this-&gt;cache-&gt;save(\n            $this-&gt;serializer-&gt;serialize($cacheData),\n            $cacheKey,\n            &#091;$cacheTag],\n            86400\n        );\n    }\n\n    public function getCache() {\n        $cacheKey  = \\Webkul\\CustomCache\\Model\\Cache\\Type::TYPE_IDENTIFIER;\n        $data = $this-&gt;serializer-&gt;unserialize( \n            $this-&gt;cache-&gt;load($cacheKey)\n        );\n    }\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Create di.xml to Inject Custom Cache Type<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\n    xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager\/etc\/config.xsd&quot;&gt;\n    \n    &lt;type name=&quot;Webkul\\CustomCache\\Model\\OperateCustomCache&quot;&gt;\n        &lt;arguments&gt;\n            &lt;argument name=&quot;cache&quot; xsi:type=&quot;object&quot;&gt;Webkul\\CustomCache\\Model\\Cache\\Type&lt;\/argument&gt;\n        &lt;\/arguments&gt;\n    &lt;\/type&gt;\n    \n&lt;\/config&gt;<\/pre>\n\n\n\n<p>You have to take care of passing classes to the constructor of the class that is responsible for saving and getting cached data. As shown below.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\"> \/**\n  * @param FrontendInterface $cache\n  * @param SerializerInterface $serializer\n  *\/\n public function __construct(FrontendInterface $cache, SerializerInterface $serializer)\n {\n     $this-&gt;cache = $cache;\n     $this-&gt;serializer = $serializer;\n }<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">The code section of the class &#8220;Webkul\\CustomCache\\Model\\OperateCustomCache&#8221; is responsible for storing data in the cache. <\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\"> $cacheKey  = \\Webkul\\CustomCache\\Model\\Cache\\Type::TYPE_IDENTIFIER;\n $cacheTag  = \\Webkul\\CustomCache\\Model\\Cache\\Type::CACHE_TAG;\n\n $time = date(&#039;Y-m-d H:i:s&#039;);\n $cacheData = &#091;\n     &#039;name&#039; =&gt; &#039;Webkul&#039;,\n     &#039;type&#039; =&gt; &#039;Custom Cache&#039;,\n     &#039;description&#039; =&gt; &#039;This is custom cache created by Webkul&#039;,\n     &#039;created_at&#039; =&gt; $time\n ];\n $storeData = $this-&gt;cache-&gt;save(\n     $this-&gt;serializer-&gt;serialize($cacheData),\n     $cacheKey,\n     &#091;$cacheTag],\n     86400\n );<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><br>The code section of class &#8220;Webkul\\CustomCache\\Model\\OperateCustomCache&#8221; is responsible for retrieving data from the cache type<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\">$cacheKey  = \\Webkul\\ModuleName\\Model\\Cache\\Type\\CacheType::TYPE_IDENTIFIER;\n\n$data = $this-&gt;serializer-&gt;unserialize($this-&gt;cache-&gt;load($cacheKey));<\/pre>\n\n\n\n<p>Overall, creating a custom cache type in Magento 2 can help improve the performance and scalability of your store.<\/p>\n\n\n\n<p>By caching frequently accessed data, you can reduce the load on your server and improve the user experience for your customers.<\/p>\n\n\n\n<p>If you\u2019re looking for expert help implementing this architecture, trust a seasoned&nbsp;<a href=\"https:\/\/webkul.com\/magento-development\/\">Magento development company<\/a>&nbsp;to bring your vision to life.<\/p>\n\n\n\n<p>Know more about&nbsp;<a href=\"https:\/\/developer.adobe.com\/commerce\/php\/architecture\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 architecture<\/a>.<\/p>\n\n\n\n<p>Continue Reading -&gt;&nbsp;<a href=\"https:\/\/webkul.com\/blog\/magento-2-development-02-list-of-magento-important-terminal-commands\/\">Magento 2 Commands List<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Discover the step-by-step process to build a custom Magento 2 cache type, including all important configuration and implementation details Here is a brief summary of the steps involved: Creating a new module named &#8220;CustomCache&#8221;, the module directory is app\/code\/Webkul\/CustomCache. Now create a new directory called &#8220;etc&#8221; inside your module directory and create &#8220;cache.xml&#8221; file at <a href=\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":169,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13710,9121,1],"tags":[1317,2070],"class_list":["post-377684","post","type-post","status-publish","format-standard","hentry","category-caching","category-magento-2","category-uncategorized","tag-cache","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create a custom cache type in Magento<\/title>\n<meta name=\"description\" content=\"Learn how to implement a custom cache type in Magento 2, complete with easy-to-follow instructions and code snippets.\" \/>\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\/how-to-create-a-custom-cache-type-in-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create a custom cache type in Magento\" \/>\n<meta property=\"og:description\" content=\"Learn how to implement a custom cache type in Magento 2, complete with easy-to-follow instructions and code snippets.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-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=\"2023-04-20T17:25:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-13T11:24:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-1200x583.png\" \/>\n<meta name=\"author\" content=\"Ramakant Pandey\" \/>\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=\"Ramakant Pandey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/\"},\"author\":{\"name\":\"Ramakant Pandey\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/e900dd4548d308477830b501e60214fa\"},\"headline\":\"How to create a Custom Cache type in Magento2\",\"datePublished\":\"2023-04-20T17:25:56+00:00\",\"dateModified\":\"2026-02-13T11:24:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/\"},\"wordCount\":372,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-1200x583.png\",\"keywords\":[\"cache\",\"Magento2\"],\"articleSection\":[\"Caching\",\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/\",\"name\":\"How to create a custom cache type in Magento\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-1200x583.png\",\"datePublished\":\"2023-04-20T17:25:56+00:00\",\"dateModified\":\"2026-02-13T11:24:04+00:00\",\"description\":\"Learn how to implement a custom cache type in Magento 2, complete with easy-to-follow instructions and code snippets.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType.png\",\"width\":1290,\"height\":627,\"caption\":\"customCacheType\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create a Custom Cache type in Magento2\"}]},{\"@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\/e900dd4548d308477830b501e60214fa\",\"name\":\"Ramakant Pandey\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1ea0042b92622eca16d3d8512f51f69bb43d023e0a40fa07bfc6fc5ca068f56c?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\/1ea0042b92622eca16d3d8512f51f69bb43d023e0a40fa07bfc6fc5ca068f56c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ramakant Pandey\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/ramakant-pandey019\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create a custom cache type in Magento","description":"Learn how to implement a custom cache type in Magento 2, complete with easy-to-follow instructions and code snippets.","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\/how-to-create-a-custom-cache-type-in-magento2\/","og_locale":"en_US","og_type":"article","og_title":"How to create a custom cache type in Magento","og_description":"Learn how to implement a custom cache type in Magento 2, complete with easy-to-follow instructions and code snippets.","og_url":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-04-20T17:25:56+00:00","article_modified_time":"2026-02-13T11:24:04+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-1200x583.png","type":"","width":"","height":""}],"author":"Ramakant Pandey","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ramakant Pandey","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/"},"author":{"name":"Ramakant Pandey","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/e900dd4548d308477830b501e60214fa"},"headline":"How to create a Custom Cache type in Magento2","datePublished":"2023-04-20T17:25:56+00:00","dateModified":"2026-02-13T11:24:04+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/"},"wordCount":372,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-1200x583.png","keywords":["cache","Magento2"],"articleSection":["Caching","Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/","url":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/","name":"How to create a custom cache type in Magento","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType-1200x583.png","datePublished":"2023-04-20T17:25:56+00:00","dateModified":"2026-02-13T11:24:04+00:00","description":"Learn how to implement a custom cache type in Magento 2, complete with easy-to-follow instructions and code snippets.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/04\/customCacheType.png","width":1290,"height":627,"caption":"customCacheType"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-create-a-custom-cache-type-in-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create a Custom Cache type in Magento2"}]},{"@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\/e900dd4548d308477830b501e60214fa","name":"Ramakant Pandey","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1ea0042b92622eca16d3d8512f51f69bb43d023e0a40fa07bfc6fc5ca068f56c?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\/1ea0042b92622eca16d3d8512f51f69bb43d023e0a40fa07bfc6fc5ca068f56c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ramakant Pandey"},"url":"https:\/\/webkul.com\/blog\/author\/ramakant-pandey019\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/377684","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\/169"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=377684"}],"version-history":[{"count":25,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/377684\/revisions"}],"predecessor-version":[{"id":526342,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/377684\/revisions\/526342"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=377684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=377684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=377684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}