How does Cloudflare Disable Caching For Subdomain? Let’s find out more…
As part of our Server Management Service, Bobcares responds to all concerns.
Let’s take a closer look at Cloudflare disabling cache for a subdomain.
Cloudflare Disable Caching For Subdomain
Unless an Edge Cache TTL page rule overrides the headers, Cloudflare respects the following order of the origin web server’s cache headers.
- If the Cache-Control header is set to private, no-store, no-cache, or max-age=0, or if a cookie is present in the response, Cloudflare does not cache the resource.
- Cloudflare caches when the Cache-Control header is set to public and the max-age is greater than 0. Else, when the Expires header is set to a future date.
While the vast majority of requests to the domains benefit from Cloudflare caching, the sub-domain that only contains scripts does not as the content is not cache-able. Hence we may also need to disable caching for subdomains.
The CDN for Cloudflare offers various options for customizing cache. It includes:
- Using Cloudflare Page Rules, we can cache individual URLs.
- Utilizing Cloudflare Workers, we can customize caching.
- With the Cloudflare Caching app, we can modify the caching level, cache TTL, and more.
Subdomain caching works just like regular domain caching. Cloudflare always caches static files. If we want no caching on the subdomain, we need to create a Page Rule:
Match: sub.example.com/* (matches all files and pages)
Setting: Cache Level (Bypass)
For a specific URL, we can now create a page rule (and even use wildcards) and then select Cache Level > Bypass.
Since Cloudflare caches the CSS and JS, we don’t need to enable development mode to disable this. Put the following attribute on the link or script tag if you only want to disable that particular JS or CSS.
<script data-cfasync="false" src="/javascript.js"></script>
[Do you need an answer to another question? We can help you.]
Conclusion
By default, Cloudflare does not cache HTML or PHP. Subdomain caching, on the other hand, works exactly like regular domain caching. Here, our Support team came up with an easy solution for how Cloudflare disables caching for subdomain issues with the help of Page Rule.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments