Web Hosting Site: Does Cloudflare cache .htaccess file

I’ve enabled “cache everything” in Page Rules for entire domain.
example.com/*

Occasionally I edit/update my .htaccess file on the origin server. I do purge all URLs or specific ones, but since .htaccess file can’t be accessed through my browser I don’t know if it gets cached or not.

I wanted to know:

  1. Does Cloudflare caches .htaccess file on its edge?

.htaccess file is very sensitive and it shouldn’t be disclosed to the public.

If you have WAF turned on in Cloudflare, chances are the .htaccess file request will be blocked by the WAF.

Even though it’s not blocked by Cloudflare WAF, .htaccess is not considered a static file so it won’t be cached by Cloudflare (unless you have Cache Everything rule, which probably will cache it)

2 Likes

thanks for the info. Yes, that is why when I purge specific URLs, I add https://example.com/.htaccess to purge IF in case that gets cached on cloudflare edge.

But I was not sure if it gets cached or not at edge.

You can check the response header after you purge the cache - especially take note on the “Age” header. If the “age” is only few seconds then the cached was purged.

But, may I know why you need to access .htaccess from the public?

1 Like

No I do not want to have access .htaccess file from public or browser.
I just wanted to know if it gets cached at cloudflare edge as rest of the files. My “cache everything” setting was for a “week” and since search engine bots read/access .htaccess files, I wanted them to serve latest of the change that i’ve made to that particular file.

No, .htaccess isn’t something a browser should ever request. It exists to process requests to the server and is only used internally at the origin.

Really? They shouldn’t be directly accessing that file. And as Eric said, it should be locked down for security reasons.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.