Exclude Caching for .php Files

Could anyone suggest page rules to exclude .php files from caching?

.php files don’t cache. Normally, they generate site pages, which aren’t cached. Unless you’ve added a Cache Everything Page Rule.

Cache everything except .php

That’s what I need for page rule.

.php doesn’t show up as an extension. It’s what outputs the HTML that is delivered for the URL you’re caching.

What is it you do want cached?

I didn’t think that one through. Yes, .php can show up in a URL.

Try two page rules: One to match example.com/*.php that will Bypass Cache, then the next rule to match example.com/* to Cache Everything. The first rule should trigger a match and not continue to the second rule.

Page rule with http://example.com/*.php and cache bypass causes redirect loop.

Cache Level: Cache Everything
Origin Cache Control: On
You can set cache-control in php file that you want to bypass
PHP Page with dynamic content
cache-control: no-store, no-cache, must-revalidate
cf-cache-status: BYPASS

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.