Excluding Pages, URLs, and Cookies from Cache
Some pages should never be served from the cache, such as carts, checkout, and account pages. This guide explains the three settings that control what xSpeed Cache skips, and how the matching patterns work.
What this does
xSpeed Cache lets you keep certain requests out of the page cache based on:
- The page URL (Excluded URLs)
- A cookie the visitor is carrying (Excluded Cookies)
- Query parameters in the link (Ignored Query Parameters)
The first two skip caching entirely for matching requests. The third does something different: it removes certain query parameters before deciding which cache entry to use, so similar links share one cached copy.
How matching works
All three settings use the same pattern rules. You enter one pattern per line. Each pattern can be written in one of three ways:
- Plain text (contains). A pattern with no special characters matches anywhere in the text. For example,
/cartmatches/cart,/cart/items, and/foo/cart/bar. - Glob (anchored). Adding
*,?, or[ ]switches to anchored matching against the whole value.*matches any run of characters (including/), and?matches one character. For example,/cart/*matches/cart/itemsbut not/foo/cart/bar.*.pdfmatches PDF URLs. - Raw regex. A pattern that starts with
~is treated as a regular expression. For example,~wp-.*\.phpmatcheswp-login.php,wp-cron.php, and similar. This lets you paste regex-style exclusion lists from other caching tools by adding the~marker.
Note: An invalid or very long regex is rejected safely. It simply matches nothing, rather than causing an error.
Excluded URLs
Any request whose URL path matches one of these patterns is not cached.
The defaults already cover the common cases:
- Admin and API paths:
/wp-admin/,/wp-json/,/xmlrpc.php,~wp-.*\.php,/wp-login - Feeds and sitemaps:
/feed/,~sitemap(_index)?\.xml,index.php - Store pages:
/cart,/checkout,/my-account,/wc-api,/edd-api - A few cache-busting markers:
ao_noptirocket,ao_speedup_cachebuster,removed_item
Because /cart, /checkout, and /my-account are written as plain text with no trailing slash, they match both /cart and /cart/items, which is what WooCommerce serves.
Add your own lines for any other pages that must stay dynamic, such as a custom account area.
Excluded Cookies
If a visitor’s request carries a cookie whose name matches one of these patterns, the request is not served from the cache. xSpeed Cache checks cookie names only, not their values.
This is how logged-in, commenter, and shopping visitors avoid getting a shared cached page. The defaults include patterns such as:
comment_author,comment_,wp-postpass,wordpress_no_cache,wordpress_logged_in,wordpress, and~wordpress_[a-f0-9]+for WordPress sessions and commentswoocommerce_,woocommerce_items_in_cart,edd_,edd_items_in_cart,fct_cart_hashfor store sessions- Other plugin cookies such as
jetpack,yith_wcwl_session_,yith_wrvp_,wpsc_,ecwid,ec_,xf_, andbookly
In short: once a shopper adds something to their cart or a visitor logs in, the matching cookie keeps their pages out of the shared cache.
Ignored Query Parameters
This setting works differently from the other two. Instead of skipping the cache, it strips listed query parameters before xSpeed Cache builds the cache key.
The result is that /post?utm_source=newsletter and /post share one cached copy, instead of creating a separate cache entry for every tracking link.
The defaults cover common analytics, ad, and session parameters, including:
~utm_[a-zA-Z0-9_-]+,fbclid,gclid,dclid,msclkid,mc_cid,mc_eid,mkt_tok_ga,_ke,ref,epik,usqp, and session-style keys like~[a-zA-Z0-9_-]+_sidand~session_[a-zA-Z0-9_-]+_alive
Important: Only parameters on this list are ignored. If a request carries any other query parameter, xSpeed Cache treats the request as unique and does not serve it from the cache. Add a parameter here when it does not change the page content and you want those links to share one cached copy.
How to set it up
- Open the xSpeed Cache Cache page in your WordPress admin.
- Find Excluded URLs, Excluded Cookies, or Ignored Query Parameters.
- Add one pattern per line.
- Save your settings. Saving purges the cache so the new rules apply.
Best practices
- Keep the defaults. They already protect carts, checkout, account, login, and admin pages.
- When in doubt, use plain text. The “contains” behavior is the easiest to predict.
- Use glob (
/path/*) when you want to match a section but not stray matches elsewhere in the URL. - Only reach for
~regex when you need to match a varying pattern, such as a hashed cookie name.
Troubleshooting
- A page I expected to cache shows MISS. Check whether its URL matches an excluded pattern, whether the visitor carries an excluded cookie, or whether the link includes a query parameter that is not on the ignored list.
- A dynamic page is being cached. Add its URL to Excluded URLs, or add the cookie it sets to Excluded Cookies.
FAQ
Does Excluded Cookies match cookie values? No. It matches cookie names only.
Why are carts and checkout already excluded?
The defaults include /cart, /checkout, /my-account, and the common store session cookies, so dynamic store pages stay out of the cache without extra setup.
Related
- How to Enable Page Cache
- Setting Cache Lifetime (TTL)
- Bypassing Cache by User Agent