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 %{REQUEST_METHOD} GET
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?