WAF Custom Rule - Enabling a URI path whitelist custom rule makes my website super laggy
I'm using Cloudflare proxy primarily interested in its WAF rules and API Gateway related features. I created a custom Rule to whitelist only the valid URI paths to prevent sending invalid path requests to my origin load balancer. I'm aware Cloudflare has their own managed DDoS rules but they're not mitigated. Maybe because I'm under the free plan, Idk.
When this custom Rule is enabled, my website is super laggy and takes forever to load. But when the rule is disabled, everything works at regular speed.
I'm suspicious that Cloudflare having to check every single path to make sure this rule doesn't block the request, it makes it slow. But I was under the impression that Cloudflare caches everything.
Your help and guidance is appreciated.
Thank you

2 Replies
Support AI
I'm happy to help you troubleshoot the issue.
It's great that you've created a custom rule to whitelist valid URI paths. However, the performance impact you're experiencing is likely due to the rule's configuration.
According to the Cloudflare documentation, custom rules can indeed impact performance, especially if they're not optimized. (Source: https://developers.cloudflare.com/rules/)
Regarding caching, Cloudflare does cache content, but it's not a guarantee that every request will be cached. The caching behavior depends on various factors, including the type of request, headers, and cache settings. (Source: https://developers.cloudflare.com/cache/how-to/cache-rules/create-dashboard/)
To improve performance, I recommend reviewing your custom rule's configuration and consider the following:
1. Optimize your rule expression: Make sure your rule expression is efficient and doesn't cause excessive processing overhead. You can use the Rule Expression Builder to help you craft a more efficient expression.
2. Use a more specific filter: Instead of checking every single path, try to narrow down the filter to only the specific paths that need to be whitelisted. This can help reduce the number of requests that need to be evaluated.
3. Check cache settings: Ensure that caching is enabled for your website and that the cache settings are configured correctly. You can check the cache settings in the Cloudflare dashboard under Caching > Configuration.
4. Consider using a different approach: If the custom rule is still causing performance issues, you might want to explore alternative approaches, such as using Cloudflare's Rate Limiting Rules or Managed Rules.
If you're still experiencing issues after optimizing your custom rule, feel free to provide more details about your rule configuration, and I'll do my best to help you troubleshoot the issue.
Sources
This is an AI generated response, it may not be 100% accurate. Please validate the output. You can ask followups by replying to this message or mentioning me.
We will have to evaluate the rule but it should be extremely quick, the rule itself is very simple. Have you got a url we can look at?