I have a blog listing page, which I would like to cache using Blitz.

However, when a user searches the blog (/blog?search=something) I'd like to load the un-cached version.

I'm using server rewrite to serve static pages, so I excluded the search query parameter:

RewriteCond %{DOCUMENT_ROOT}/cache/blitz/%{HTTP_HOST}/%{REQUEST_URI}/index.html -s
RewriteCond %{QUERY_STRING} !(^token|^search|^success)= [NC]
RewriteRule .* /cache/blitz/%{HTTP_HOST}/%{REQUEST_URI}/index.html [L]

I then tried excluding the page using a regular expression (.+?search=) in the exclude URIs section. However, it seems to only support exclusion by the base URL, without the query parameters.

Next I tried to set an exclusion on the Advanced Settings tab, where my selected option is "Cache URLs with query strings as the same page". However, this did not have an effect and the page was still cached when the ?search query was present. The documentation on this option says:

The query string parameters to include or exclude when determining if and how a page should be cached (regular expressions may be used).

Which is somewhat cryptic to my understanding. I assume it serves to minimize the number of unique versions when the "Cache URLs with query strings as unique pages" is selected, but I'm not sure how it works when "Cache URLs with query strings as the same page" is selected.

Is there an obvious way to achieve this that does not entail excluding the "bare" version of the blog as well?

1 Answer 1


Excluded URI patterns apply to the URI only and not to the query string. For that reason, I'd recommend changing your URI structure so that the cached blog page exists at /blog, whereas uncached search pages exist at /blog/search. That way you can exclude the latter from being cached and achieve your desired result, either by using a query string such as /blog/search?query=something or by setting up a route such as /blog/search/* which will allow a URI of /blog/search/something to work.

  • Thanks Ben. That's a good workaround. I was hoping this is possible with the current setup, but your answer clarifies it's not supported.
    – Matanya
    Commented Nov 27, 2022 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.