{"id":36152,"date":"2024-05-24T15:07:50","date_gmt":"2024-05-24T15:07:50","guid":{"rendered":"https:\/\/www.wpstaq.com\/?post_type=knowledgebase&#038;p=36152"},"modified":"2024-07-03T06:02:02","modified_gmt":"2024-07-03T06:02:02","slug":"nonce-and-cache-ttl","status":"publish","type":"knowledgebase","link":"https:\/\/www.wpstaq.com\/hk\/knowledgebase\/nonce-and-cache-ttl\/","title":{"rendered":"Nonce and Cache TTL"},"content":{"rendered":"<h2><strong>What is a Nonce?<\/strong><\/h2>\n<p>A nonce, or &#8220;number used once,&#8221; is a unique token generated by WordPress to verify the origin and intent of requests, particularly in forms and AJAX calls. By default, WordPress sets nonces to expire after 12 hours, although some plugins may extend this to 24 hours for specific functionalities.<\/p>\n<h2><strong>Why Nonces Require Special Treatment?<\/strong><\/h2>\n<p>Nonces are vital for security, but once they expire, they become invalid and functions they&#8217;re tied to (such as Forms and AJAX requests) will not function.<\/p>\n<h2><strong>Available Cache TTL Settings for Clearance<\/strong><\/h2>\n<p>Staq prioritizes performance optimization by disabling the Global Time To Live (TTL) setting by default instead of the blanket N-hour sTTL approach used by other hosting platforms or caching plugins.<\/p>\n<h2><strong>Reasoning Behind Not Setting Global Cache TTL to 10 Hours<\/strong><\/h2>\n<p>By dynamically managing cache expiration based on nonce validity, Staq optimizes performance while maintaining SEO integrity. This approach ensures that only pages with expired nonces are deleted, preventing unnecessary removal of unaffected pages that could otherwise slow down your website.<\/p>\n<h3><strong>Commands for Cache Deletion<\/strong><\/h3>\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 juice:w-full juice:items-end overflow-x-auto gap-2\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"3cec1b0b-175f-44f0-ad47-29416a50e748\">\n<div class=\"flex w-full flex-col gap-1 juice:empty:hidden juice:first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>To delete expired cached files, Staq runs the WP CLI command &#8220;wp wpstaq clear-expired-cache&#8221; hourly. This initiates a scan of cached files. Staq first checks the global TTL setting for expiration. If not expired, it then evaluates the nonce rules TTL. Should the nonce TTL be exceeded, Staq inspects the content for nonces, deleting the cache if necessary.<\/p>\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 juice:w-full juice:items-end overflow-x-auto gap-2\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"9cbdaabc-3918-46af-8b9a-3b962359e3b0\">\n<div class=\"flex w-full flex-col gap-1 juice:empty:hidden juice:first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<h3><strong>Verification of Cache Deletion<\/strong><\/h3>\n<p>To verify cache deletion:<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>Check Cache Creation Timestamps: Inspect HTML source code for the Staq cache creation timestamp, typically located near the end of the document:<code>&lt;!-- Cached &amp; Optimized by Staq (https:\/\/www.wpstaq.com): YYYY-MM-DD HH:MM:SS GMT --&gt;<\/code><\/li>\n<li>Review Debug Logs: Monitor wp-content\/.wpstaq\/wpstaq.debug.log for cache deletion messages, such as:<code>0b36f2ab [24-May-2024 13:13:09 UTC] WARNING: message='File \/services expired 0.79h ago and deleted global:24h.'<br \/>\n<\/code><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>Note that logs auto-reset at 100 MB.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex gap-3 empty:hidden juice:-ml-3\">\n<div class=\"items-center justify-start rounded-xl p-1 flex\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 juice:w-full juice:items-end overflow-x-auto gap-2\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"f09abff6-dd2d-4345-8b59-4fc6a4d3bc65\">\n<div class=\"flex w-full flex-col gap-1 juice:empty:hidden juice:first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<h2><strong>Deprecating Files TTL Manager Feature<\/strong><\/h2>\n<p>In our pursuit of better management and optimization, we have deprecated the Files TTL Manager feature. Instead, users now have more streamlined options. They can set hourly TTL for specific pages either through custom plugin development or by utilizing our WP CLI command as a cron job, configurable directly from the Staq Panel:<\/p>\n<p><code>wp wpstaq clear-cache --post-id=&lt;id1&gt;,&lt;id2&gt;,...<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-36154\" src=\"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl.png\" alt=\"\" width=\"1142\" height=\"440\" srcset=\"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl.png 1142w, https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl-300x116.png 300w, https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl-1024x395.png 1024w, https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl-768x296.png 768w\" sizes=\"auto, (max-width: 1142px) 100vw, 1142px\" \/><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"featured_media":0,"parent":0,"template":"","class_list":["post-36152","knowledgebase","type-knowledgebase","status-publish","hentry","categories-caching-diagnose"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Nonce and Cache TTL - Managed Hosting Platform for WordPress<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nonce and Cache TTL - Managed Hosting Platform for WordPress\" \/>\n<meta property=\"og:description\" content=\"What is a Nonce? A nonce, or &#8220;number used once,&#8221; is a unique token generated by WordPress to verify the origin and intent of requests, particularly in forms and AJAX calls. By default, WordPress sets nonces to expire after 12 hours, although some plugins may extend this to 24 hours for specific functionalities. Why Nonces&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/\" \/>\n<meta property=\"og:site_name\" content=\"Managed Hosting Platform for WordPress\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/staqhosting\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-03T06:02:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/nonce-and-cache-ttl\\\/\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/nonce-and-cache-ttl\\\/\",\"name\":\"Nonce and Cache TTL - Managed Hosting Platform for WordPress\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/nonce-and-cache-ttl\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/nonce-and-cache-ttl\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.wpstaq.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/cron-job-ttl.png\",\"datePublished\":\"2024-05-24T15:07:50+00:00\",\"dateModified\":\"2024-07-03T06:02:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/nonce-and-cache-ttl\\\/#breadcrumb\"},\"inLanguage\":\"en-hk\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/nonce-and-cache-ttl\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-hk\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/nonce-and-cache-ttl\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/cron-job-ttl.png\",\"contentUrl\":\"https:\\\/\\\/www.wpstaq.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/cron-job-ttl.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/knowledgebase\\\/nonce-and-cache-ttl\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.wpstaq.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nonce and Cache TTL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#website\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/\",\"name\":\"Managed Hosting Platform for WordPress\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.wpstaq.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-hk\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#organization\",\"name\":\"Staq\",\"alternateName\":\"WPStaq\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-hk\",\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.wpstaq.com\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/cropped-LogoNoText.png\",\"contentUrl\":\"https:\\\/\\\/www.wpstaq.com\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/cropped-LogoNoText.png\",\"width\":512,\"height\":512,\"caption\":\"Staq\"},\"image\":{\"@id\":\"https:\\\/\\\/www.wpstaq.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/staqhosting\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/wpstaq\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nonce and Cache TTL - Managed Hosting Platform for WordPress","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:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/","og_locale":"en_US","og_type":"article","og_title":"Nonce and Cache TTL - Managed Hosting Platform for WordPress","og_description":"What is a Nonce? A nonce, or &#8220;number used once,&#8221; is a unique token generated by WordPress to verify the origin and intent of requests, particularly in forms and AJAX calls. By default, WordPress sets nonces to expire after 12 hours, although some plugins may extend this to 24 hours for specific functionalities. Why Nonces&hellip;","og_url":"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/","og_site_name":"Managed Hosting Platform for WordPress","article_publisher":"https:\/\/www.facebook.com\/staqhosting\/","article_modified_time":"2024-07-03T06:02:02+00:00","og_image":[{"url":"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/","url":"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/","name":"Nonce and Cache TTL - Managed Hosting Platform for WordPress","isPartOf":{"@id":"https:\/\/www.wpstaq.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/#primaryimage"},"image":{"@id":"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl.png","datePublished":"2024-05-24T15:07:50+00:00","dateModified":"2024-07-03T06:02:02+00:00","breadcrumb":{"@id":"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/#breadcrumb"},"inLanguage":"en-hk","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/"]}]},{"@type":"ImageObject","inLanguage":"en-hk","@id":"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/#primaryimage","url":"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl.png","contentUrl":"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2024\/05\/cron-job-ttl.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.wpstaq.com\/knowledgebase\/nonce-and-cache-ttl\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.wpstaq.com\/"},{"@type":"ListItem","position":2,"name":"Nonce and Cache TTL"}]},{"@type":"WebSite","@id":"https:\/\/www.wpstaq.com\/#website","url":"https:\/\/www.wpstaq.com\/","name":"Managed Hosting Platform for WordPress","description":"","publisher":{"@id":"https:\/\/www.wpstaq.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wpstaq.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-hk"},{"@type":"Organization","@id":"https:\/\/www.wpstaq.com\/#organization","name":"Staq","alternateName":"WPStaq","url":"https:\/\/www.wpstaq.com\/","logo":{"@type":"ImageObject","inLanguage":"en-hk","@id":"https:\/\/www.wpstaq.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2023\/05\/cropped-LogoNoText.png","contentUrl":"https:\/\/www.wpstaq.com\/wp-content\/uploads\/2023\/05\/cropped-LogoNoText.png","width":512,"height":512,"caption":"Staq"},"image":{"@id":"https:\/\/www.wpstaq.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/staqhosting\/","https:\/\/www.linkedin.com\/company\/wpstaq"]}]}},"_links":{"self":[{"href":"https:\/\/www.wpstaq.com\/hk\/wp-json\/wp\/v2\/knowledgebase\/36152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wpstaq.com\/hk\/wp-json\/wp\/v2\/knowledgebase"}],"about":[{"href":"https:\/\/www.wpstaq.com\/hk\/wp-json\/wp\/v2\/types\/knowledgebase"}],"wp:attachment":[{"href":"https:\/\/www.wpstaq.com\/hk\/wp-json\/wp\/v2\/media?parent=36152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}