Cloudflare APO doesn't refresh home page in mobile devices when Cache By Device Type is enabled

I’ve always used Cloudflare APO and I’ve never had a problem with my site’s home page updating when I make new posts or changes. (I had never used the Cache by Device Type option before)

Recently, I needed to enable the “Cache by Device Type” option, but I noticed a problem. After I made a post on my site, I noticed that my site’s homepage only updated on its PC version, while the site on the mobile version remained the same, it was not updated, and it did not show the new post that I had published .

I got to do tests. I cleared all browser data/cache on my phone, tested it on other browsers, and the homepage was still not updated.

I use the WP-Rocket plugin, and it also has the option to cache by device type enabled. I didn’t need to change anything on it. My first action was to purge Cloudflare’s cache, and as soon as I did that, the homepage of my website on mobile devices, in this case the cell phone, was successfully updated and the new post appeared.

What to do in a situation like this? Because logically speaking, the cache should be updated for all device types when “Cache by Device Type” is enabled and some publication or change is performed, right?

I did some tests, and it’s not just the mobile homepage of my website that doesn’t update, but also the posts.I edited some of them, and while the updated version of them appeared normally on the PC version of my site, on mobile, the posts remained in the previous version.

It makes no sense…

I have a test website with APO for WordPress and Cache by Device Type enabled. I just added a post to test it, and I got the expected updated initial page on all variants (desktop, tablet, mobile) — except for some Safari requests on a very old tablet, which I blame on Safari’s own persistent cache policy. So this doesn’t seem to be an APO issue per se.

I’d focus on the interaction between Cloudflare and your local settings. On the Cloudflare side, make sure you don’t have any Page Rules or Cache Rules that may be overriding APO in terms of caching. On the WordPress side, besides your caching plugin, make sure you check your theme’s configurations for any related settings.

I never created any cache rule or page rule in my Cloudflare. I also didn’t find any pertinent settings in my theme’s settings.

Will I have to purge everything every time I publish something on my site? I tried the custom purge option, to just purge the home page or post in question, but apparently it didn’t work.

Not if you have your site set correctly. APO will detect any new content and purge only the necessary pages. I just edited an old post in my test APO website and it instantly updated the content of the post on both desktop and mobile versions. So it doesn’t seem to be an issue with APO, but something with your settings.

You may want to raise the issue with WP-Rocket developers after performing a :search: on their support forum.

1 Like

I already did tests with WP-Rocket disabled, and the problem unfortunately persisted.

Are there any custom caching settings I might be setting so that my site’s homepage cache is custom refreshed from time to time?

You could set a Cache Rule for the homepage with an Edge Cache TTL set to whatever time in seconds you think it’s good, OR set it to respect origin headers and make sure your origin is sending a “must-revalidate” instruction as part of your Cache-Control header for the homepage. In any case, you need to set and test, and always remember to purge the relevant caches while testing.

It’s curious because I found some webpages from several users reporting the same problem (despite being old dates).

I hope it’s not a problem that has come back.

The first link points to an unrelated issue of which Cloudflare is aware, and for which a temporary solution was proposed here.

As for the issue this topic is about, as I have said, I have a test APO site with local cache turned off, and both homepage cache and that of pages with updated content is purged correctly by APO, for mobile, tablet, and desktop devices.

Have you reached out to your caching plugin developers as suggested?

For some reason I don’t know, now the mobile cache is updating normally, which is good.

About the plugin issue, I had tested it with it disabled, and the problem persisted.

Anyway, the mobile cache is updating again!

1 Like

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