{"id":21802,"date":"2020-05-27T08:43:28","date_gmt":"2020-05-27T12:43:28","guid":{"rendered":"https:\/\/www.boldgrid.com\/support\/?p=21802"},"modified":"2024-02-22T09:46:48","modified_gmt":"2024-02-22T14:46:48","slug":"how-to-implement-page-fragment-caching-exception-in-w3-total-cache","status":"publish","type":"post","link":"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/how-to-implement-page-fragment-caching-exception-in-w3-total-cache\/","title":{"rendered":"How to Implement Page Fragment Caching Exception in W3 Total Cache"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"utf-8\" ?><html><body><p>When implementing a Page Fragment Caching Exception, you are telling W3 Total Cache to bypass cache for a particular section of content. A great use case for this is dynamic content that you wish to update real time, separate of the page caching itself. The following article will walk you through the process.<\/p>\n<div class=\"boldgrid-section\" style=\"margin-top: 60px;\">\n<div class=\"container w3tc-radius\" style=\"border-width: 0px; background-image: url('https:\/\/www.boldgrid.com\/wp-content\/uploads\/2023\/07\/upsell-darker-alt.png'); background-size: cover; background-position: 50% 5%;\" data-image-url=\"https:\/\/www.boldgrid.com\/wp-content\/uploads\/2023\/07\/upsell-darker-alt.png\">\n<div class=\"row upsell-column\" style=\"padding-top: 2em; padding-bottom: 2em; color: #ffffff;\">\n<div class=\"col-lg-1 col-md-1 col-sm-12 col-xs-12 hidden-sm\">&nbsp;<\/div>\n<div class=\"col-lg-5 col-md-6 col-xs-12 col-sm-7\">\n<p class=\"h3\" style=\"color: #ffffff; line-height: 40px; margin-top: 0;\"><strong>Speed Up Your WordPress Website.<\/strong><\/p>\n<p style=\"color: #ffffff;\" class=\"h4\">A Difference of Just 100ms in Page Load Speeds Can Cause a Visitor to Prefer Your Competitor&rsquo;s Website.<\/p>\n<\/div>\n<div class=\"col-lg-6 col-md-5 col-sm-5 col-xs-12 text-center align-column-center\">\n<p class=\"\" style=\"border-width: 0px;\"><a class=\"button-w3tc-white\" style=\"border: 2px solid #30BEC4; font-size: 18px; padding: 15px 30px;\" href=\"https:\/\/www.boldgrid.com\/w3-total-cache\/#pricing\">View Plans<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<ul>\n<li>Select your fragment caching method in Performance &rarr; General Settings\n<ul>\n<li>We recommend you choose a <a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/configuring-w3-total-cache-for-wordpress-with-vps-or-dedicated-hosting\/\">memory-based caching backend such as Redis or memcached<\/a><\/li>\n<\/ul>\n<\/li>\n<li>Enable &ldquo;late initialization&rdquo; on the Page Cache settings page<\/li>\n<li>Add define(&lsquo;W3TC_DYNAMIC_SECURITY&rsquo;, &lsquo;mycode&rsquo;); to your wp-config.php file<\/li>\n<\/ul>\n<p>And finally, use this format to implement the caching exception in your template for the dynamic content:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/harryjackson1221\/d13cf3c9a99807e08440ca4af9581819.js\"><\/script><\/p>\n<hr>\n<h2 id=\"implementing-a-page-fragment-caching-exception-for-comments-in-twenty-twenty\">Implementing a Page Fragment Caching Exception for Comments in Twenty Twenty<\/h2>\n<p>The following example demonstrates how to configure an exception group for blog post comments using the default WordPress theme, Twenty Twenty and W3 Total Cache.<\/p>\n<p>Resources:<\/p>\n<ul>\n<li>Twenty Twenty theme<\/li>\n<li>Twenty Twenty child theme<\/li>\n<\/ul>\n<p>Install both themes in your WordPress installation and activate the Twenty Twenty child theme.<\/p>\n<p>Copy the comments.php file from the Twenty Twenty theme over to the child theme root directory.<\/p>\n<p>Install and activate W3 Total Cache and set your Pro license.<\/p>\n<p>Navigate to <b>Performance<\/b> &gt; <b>General Settings<\/b> and enable <b>Page Cache<\/b>.&nbsp; If you do not have memory based caching available on your server (Redis or Memcached) the select <b>Disk: Basic<\/b> for the <b>Page Cache Method<\/b>.<\/p>\n<p>Access your Page Cache settings by navigating to <b>Performance<\/b> &gt; <b>Page Cache<\/b> in your WordPress dashboard and enable <b>Late initialization<\/b> under the <b>Advanced<\/b> section.<\/p>\n<p>Add the code <b>define(&lsquo;W3TC_DYNAMIC_SECURITY&rsquo;, &lsquo;comments&rsquo;);<\/b> to the wp-config. php file associated with your website just before the line <b>\/* That&rsquo;s all, stop editing! Happy publishing. *\/<\/b><\/p>\n<p>Open comments.php located in your child theme directory using your preferred text editor.<\/p>\n<p>Locate the wp_list_comments function and wrap it in your <b>&lt;!&ndash; mfunc comments&ndash;&gt;<\/b> opening and closing tags.&nbsp; Your code should look like this:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/harryjackson1221\/139f8c84e65286d46c871a1357f94833.js\"><\/script><\/p>\n<p>&nbsp;<\/p>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>When implementing a Page Fragment Caching Exception, you are telling W3 Total Cache to bypass cache for a particular section of content. A great use case for this is dynamic content that you wish to update real time, separate of the page caching itself. The following article will walk you through the process. &nbsp; Speed [&hellip;]<\/p>\n","protected":false},"author":529,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"bgseo_title":"How to Implement Page Fragment Caching Exception in W3 Total Cache","bgseo_description":"When implementing a Page Fragment Caching Exception, you are telling W3 Total Cache to bypass cache for a particular section of content. The following article will walk you through the process. \r\n","bgseo_robots_index":"index","bgseo_robots_follow":"follow","footnotes":""},"categories":[740,692],"tags":[],"class_list":["post-21802","post","type-post","status-publish","format-standard","hentry","category-page-cache","category-w3-total-cache"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/21802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/users\/529"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/comments?post=21802"}],"version-history":[{"count":6,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/21802\/revisions"}],"predecessor-version":[{"id":125507,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/21802\/revisions\/125507"}],"wp:attachment":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/media?parent=21802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/categories?post=21802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/tags?post=21802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}