Page rule with GET


#1

Hi!
A have page site.com/status.php
And a lot of request send like site.com/status.php?hash=123123
That means page opens w/o cache using, but this page make a lot of sql queries, and i need to always use 30 min cache for users. So i think i just need to redirect users to page w/o hash parameter, so they will get cached page.
What should i use in page rules, to get that result?


#2

Something like a Forwarding URL (302, temp redirect): site.com/status.php?hash=* to http://site.com/status.php (or https) would accomplish what you ask.

But you could also create a rule for the status.php where the cache level is set to ‘ignore query strings’ which may be a more correct way of accomplishing your desired end result. You could possibly even set this caching level as your domain-wide setting if it doesn’t impact any of you other site behaviour.


#3

Try choosing “ignore query string” in the caching section of your administration console. However, by default Cloudflare only caches static assets. So you may need to use a page rule with cache everything depending on your needs.


#4

@cscharff mentioned “ignore query string” - note this can only be applied to static file extensions right now, or all file extensions as part of Custom Cache Keys on our Enterprise plan.

With that in mind, I think @saul’s idea to redirect to the correct URL and then (optionally) enabling cache everything on the correct URL with a separate page rule is a good one. This will force all visitors to the primary URL and leverage caching too.