{"id":4656,"date":"2026-06-22T18:20:19","date_gmt":"2026-06-22T15:20:19","guid":{"rendered":"https:\/\/fastpixel.io\/?post_type=docs&#038;p=4656"},"modified":"2026-06-22T18:26:34","modified_gmt":"2026-06-22T15:26:34","password":"","slug":"what-is-vary-cache","status":"publish","type":"docs","link":"https:\/\/fastpixel.io\/fr\/docs\/what-is-vary-cache\/","title":{"rendered":"What is Vary Cache?"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Vary Cache is a new feature in FastPixel which will store <strong>different cached versions of the same page depending on the value of one or more cookies<\/strong> you choose.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Normally, a page cache works like this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>User A visits <code>\/about<\/code><\/li>\n\n\n\n<li>The page is generated and cached<\/li>\n\n\n\n<li>User B visits <code>\/about<\/code><\/li>\n\n\n\n<li>User B gets the same cached page<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">With cookie-based variation:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>User A has cookie <code>membership=gold<\/code><\/li>\n\n\n\n<li>User B has cookie <code>membership=silver<\/code><\/li>\n\n\n\n<li>The cache stores separate versions of <code>\/about<\/code> for each cookie value<\/li>\n\n\n\n<li>Each user receives the correct cached content<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Please note that Vary Cache will not work if you do not set one or more important cookies!<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"267\" src=\"https:\/\/fastpixel.io\/wp-content\/uploads\/2026\/06\/image-1024x267.png\" alt=\"\" class=\"wp-image-4660\" style=\"width:633px;height:auto\" srcset=\"https:\/\/fastpixel.io\/wp-content\/uploads\/2026\/06\/image-1024x267.png 1024w, https:\/\/fastpixel.io\/wp-content\/uploads\/2026\/06\/image-300x78.png 300w, https:\/\/fastpixel.io\/wp-content\/uploads\/2026\/06\/image-768x200.png 768w, https:\/\/fastpixel.io\/wp-content\/uploads\/2026\/06\/image-1536x400.png 1536w, https:\/\/fastpixel.io\/wp-content\/uploads\/2026\/06\/image-18x5.png 18w, https:\/\/fastpixel.io\/wp-content\/uploads\/2026\/06\/image-360x94.png 360w, https:\/\/fastpixel.io\/wp-content\/uploads\/2026\/06\/image.png 1628w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Why it&#8217;s needed<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Some websites show different content based on cookies, such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Logged-in vs logged-out users<\/li>\n\n\n\n<li>Membership levels<\/li>\n\n\n\n<li>Geographic preferences<\/li>\n\n\n\n<li>Language selectors<\/li>\n\n\n\n<li>A\/B testing variants<\/li>\n\n\n\n<li>WooCommerce cart\/session states<\/li>\n\n\n\n<li>Location based currency or tax<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Without varying by cookie, users could see the wrong content because everyone would receive the same cached page.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Trade-offs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Pros<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Allows caching personalized content.<\/li>\n\n\n\n<li>Improves performance compared to disabling cache entirely.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cons<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Can dramatically increase cache size if cookie values are highly variable.<\/li>\n\n\n\n<li>May reduce cache hit rates because fewer visitors share the same cached page.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Important caution<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Avoid varying by cookies that contain unique values per visitor, such as:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>session_id=abc123\n\nsession_id=xyz789<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This effectively creates a separate cache for every user, defeating most of the performance benefits of page caching.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A good rule is: <strong>only vary by cookies that have a small number of possible values and actually affect what is rendered on the page.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>","protected":false},"excerpt":{"rendered":"<p>Vary Cache is a new feature in FastPixel which will store different cached versions of the same page depending on the value of one or more cookies you choose. Normally, a page cache works like this: With cookie-based variation: Please note that Vary Cache will not work if you do not set one or more [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","footnotes":""},"doc_category":[13],"doc_tag":[],"class_list":["post-4656","docs","type-docs","status-publish","hentry","doc_category-fastpixel-website-accelerator"],"blocksy_meta":[],"year_month":"2026-06","word_count":263,"total_views":"22","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Adrian","author_nicename":"adrian","author_url":"https:\/\/fastpixel.io\/fr\/blog\/author\/adrian\/"},"doc_category_info":[{"term_name":"FastPixel Website Accelerator","term_url":"https:\/\/fastpixel.io\/fr\/docs-category\/fastpixel-website-accelerator\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"trp-custom-language-flag":false,"betterdocs-category-thumb":false},"uagb_author_info":{"display_name":"Adrian","author_link":"https:\/\/fastpixel.io\/fr\/blog\/author\/adrian\/"},"uagb_comment_info":0,"uagb_excerpt":"Vary Cache is a new feature in FastPixel which will store different cached versions of the same page depending on the value of one or more cookies you choose. Normally, a page cache works like this: With cookie-based variation: Please note that Vary Cache will not work if you do not set one or more\u2026","_links":{"self":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/comments?post=4656"}],"version-history":[{"count":5,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4656\/revisions"}],"predecessor-version":[{"id":4663,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4656\/revisions\/4663"}],"wp:attachment":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/media?parent=4656"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/doc_category?post=4656"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/doc_tag?post=4656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}