Minimize Redirects - how to enable cache for just one directory?


#1

I’ve noticed in the past year that my site speed while on CloudFlare has depreciated greatly.

I discovered this article about shared hosting and cloudflare minimize redirects issue. It is solved by pausing cloudflare or going into Development mode.

Apparently Cloudflare are working on it but the consensus is not to hold one’s breath.

So I’d like to know if the following is possible and will it work to prevent the minimize redirects?

Can I only enable cloudflare caching on one directory? I have .html and wordpress pages and would like caching only available on the wordpress directory and not the html directories (they load fast and are dramatically slowed by cloudflare on this issue)

I use Cloudflare SSL

My directory structure is like this:
www.example.com
www.example.com/catergory/page.html (this is a directory I don’t want to cache)
www.example.com/catergory/categoryagain/page.html (this is a directory I don’t want to cache)
www.example.com/blog/blogpost/ (this is the directory I want to cache)

Using pagerules I “think” I need the following

https://www.example.com/blog/* - cache everything
https://www.example.com/* - bypass cache

Or do I make the following page rule

example.com/?static=true
[adding static=true query parameter]

(this bypasses all html files)

And then select Cache everything which will cache all wordpress php files?

Would I be correct in one of the above or will this not help with the minimise redirects as described in the linked post at the top? They said “pause cloudflare” and the issue will stop — I’ve confirmed this and am presuming the issue is caching? Maybe I’m wrong and there’s another way to stop this?


#2

Hi,

It’s not clear that you are having redirect issues and what is possibly causing t. The article you linked to does not seem to demonstrate that the problem is caused by Cloudflare itself. It could be the result of that site having misconfigured Apps, for example. In case you are having redirect issues, please provide a screenshot of you issue so that members of this community can help you will it.

As for the page rules:

Using pagerules I “think” I need the following

https://www.example.com/blog/* - cache everything
https://www.example.com/* - bypass cache

The firs one should do the job of caching the HTML generated by WordPress under /blog/. You don’t need to specify the protocol https://.

www.example.com/blog/* << cache everything.

The second one is actually not necessary, as the first one shouldn’t ever be triggered for pages outside of the /blog/ in your domain.


#4

Hi

Thanks for your reply.

I’m attaching a screen shot with the redirects.

I noticed the redirects using https://gtmetrix.com as they were slowing the site down.
The urls do not come from my site at all. The pages in question are plain html
I did some online searching and came across https://marcodiversi.com/blog/minimize-redirects/ which had exactly same issue.

He says that cloudflare are gathering resources from shared hosts and the those same resources are now appearing on other sites on the shared server using cloudflare.

When he pauses cloudflare these redirects vanish. Same here. Attached is an example of these redirects - very similar to the above links issue. Again, none of these come from my pages but are being served when cloudflare is activated.

He also states he’s contacted cloudflare about it

There’s about 20 of these. Some are adsense others are for scripts I do not have like Addthis. There are even some large images being redirected.

By pausing cloudflare these all vanish.

I’m not sure if bypassing cloudflare cache will also solve this hence I’m here!


#5

People can say anything they want, that doesn’t make it remotely close to accurate. Do you have a specific URL that was used in this test?


#6

Yes, you are quite correct.

I spent the night trying to figure out where these redirects are coming from - and I found the answer. Adsense-matched content!

When clearing the Cloudflare Cache or pausing it. Adsense Balance came into effect and either less ads were shown or no ads on the next cache and so it looked like when disabling cloudflare the problem goes away. However, it doesn’t as the problem is coming from Adsense and not Cloudflare.

Thank you for helping me try to narrow down where the problem was coming from.

_If anyone else comes across this page and wants to confirm this. Then simply remove all adsense code from your page, clear cache on Cloudflare and you’ll see the problem does not return. Add in Adsense matched content or feeds and the problem comes back.

To reduce your page load from these redirects remove Adsense in page feeds/matched content and the slew of new ad spaces they have been releasing over the year.


#7

Thanks for the update. I spent a bit looking at your site, but without knowing more about the underlying code I couldn’t quite track down where the content was coming from, but suspected either ads or some smart malware which knew enough to hide from gtmrix IPs.

Glad you figured out the source. :slight_smile: