Caching breaks when using Google tag gateway
-
I have noticed that my site’s caching works fine without Google tag gateway. But using Google tag gateway breaks the caching/prefetching behavior.
- wordops
- wp super cache
- Google tag gateway (cloudflare) configured in Google Tag Manager
-
Hello there – Could you please enable debug mode in WP Super Cache to better understand why the issue is happening? Once debug mode is active, enable Google tag gateway and check if any error is getting recorded there.
You can find the steps to enable debug mode here: https://jetpack.com/support/wp-super-cache/enabling-the-debug-mode
Let us know what the log shows, and if possible could you please also provide steps on how you have implemented Google tag gateway on the site? Are you using any plugin for it?
Because of hardened security (Wordops), I was unable to access the log (403 error). I will have to modify my nginx settings later and try again.
I am using Google Tag Manager (https://ww.wp.xz.cn/plugins/duracelltomi-google-tag-manager/) with my Tag Manager’s container tag.
– Google Tag Manager ID: xxx
– Container code: ON
– Container code compatibility mode: OFFIn Google Tag Manager I then went to Admin > Google tag gateway and followed the setup to activate the gateway with my Cloudflare account.
Activating Google tag gateway makes the website become slower than usual. Looking into the cached list of files (in WP Super Cache), I can see cached files. Maybe not an issue with building the cache but rather the retrieval of pages.
I will also try to use Google Site Kit plugin instead and check if issues persists.Hello @telcy – Thanks for sharing the details. I agree that’s a good idea. Since the Site Kit by Google plugin also offers Tag Manager feature, you could try using it and deactivating your current plugin to see if that resolves the issue.
- I was not able to configure wordops to allow direct php access yet.
- Using Google site kit plugin caused the same issue.
- What I have observed:
Navigating between different pages (/page1, /page2, /page3), document loading time (browser cache disabled):
Without Google tag gateway: ~200ms
With Google tag gateway: 500 – 900msThat makes me think that there is actually an issue retrieving the document/page from the server/cache.
Here an example code for a tag gateway. Data will be routed through /ui34w instead of some Google endpoint.
<script type="text/javascript" async="" src="/ui35w/?id=AW-111222333&cx=c&gtm=45E92e283muct834hrg694za204&tag_exp=103465457~1032345026~10323454~1032353453527~1046456208~132456584211~1034537546766~105045668~10513471~10545663~10534568~105345610"></script>
<script async="" src="//www.googletagmanager.com/gtm.js?id=GTM-AO3456AEF"></script>
<script async="" src="/ui35w/"></script>Did you have any luck trying the debug log? It is generated in your wp-content/cache/ directory. It will be a PHP file with a 32 character MD5 filename. SSH to your server and you can inspect it on the command line. That should tell you why the cached files aren’t being served.
Load a page to prime the cache, then reload it and look at the logs.
When you look at the supposedly cached pages, look at the source of the page. Do they have a HTML comment at the end saying “Cached page generated by WP-Super-Cache on”? If not, then the page isn’t the cached page. Maybe the request is being intercepted somewhere. The debug log should help.
11:57:10 61160 /ueber-uns/ wpsc_is_caching_user_disabled: false
11:57:10 61160 /ueber-uns/ ACCEPT: text/html
11:57:10 61160 /ueber-uns/ wp_cache_get_cookies_values: return:
11:57:10 61160 /ueber-uns/ supercache dir: /var/www/mywebsite.de/htdocs/wp-content/cache/supercache/mywebsite.de/ueber-uns/
11:57:10 61160 /ueber-uns/ No Super Cache file found for current URL: /var/www/mywebsite.de/htdocs/wp-content/cache/supercache/mywebsite.de/ueber-uns/index-https.html
11:57:10 61160 /ueber-uns/ wp_cache_get_cookies_values: return:
11:57:10 61160 /ueber-uns/ In WP Cache Phase 2
11:57:10 61160 /ueber-uns/ Setting up WordPress actions
11:57:10 61160 /ueber-uns/ Created output buffer
11:57:10 61160 /ueber-uns/ wp_cache_get_cookies_values: return:
11:57:10 61160 /ueber-uns/ wpcache_do_rebuild: doing rebuild for /var/www/mywebsite.de/htdocs/wp-content/cache/supercache/mywebsite.de/ueber-uns/
11:57:10 61160 /ueber-uns/ wpcache_do_rebuild: exiting as directory is not a directory: /var/www/mywebsite.de/htdocs/wp-content/cache/supercache/mywebsite.de/ueber-uns/
11:57:11 61160 /ueber-uns/ wpsc_is_caching_user_disabled: false
11:57:11 61160 /ueber-uns/ Output buffer callback
11:57:11 61160 /ueber-uns/ wp_cache_get_cookies_values: return:
11:57:11 61160 /ueber-uns/ Anonymous user detected. Only creating Supercache file.
11:57:11 61160 /ueber-uns/ wpsc_is_caching_user_disabled: false
11:57:11 61160 /ueber-uns/ wp_cache_get_cookies_values: return:
11:57:11 61160 /ueber-uns/ Writing non-gzipped buffer to supercache file.
11:57:11 61160 /ueber-uns/ Renamed temp supercache file to /var/www/mywebsite.de/htdocs/wp-content/cache/supercache/mywebsite.de/ueber-uns/index-https.html
11:57:11 61160 /ueber-uns/ Sending buffer to browser
11:57:11 61160 /ueber-uns/ wp_cache_shutdown_callback: collecting meta data.
11:57:11 61160 /ueber-uns/ Did not write meta file: meta-wp-cache-0fc6b7daeead6f314c1b49c0d4674f1c.php<!-- Dynamic page generated in 0.146 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2025-08-14 13:57:11 -->
<!-- super cache -->Cache looks fine to me.
Still the page/document response time increases from 200ms to 700ms+ when activating Google tag gateway (disabled browser cache).
-
This reply was modified 9 months, 3 weeks ago by
telcy.
It seems I can reproduce this issue with tools like Zaraz (e.g. Google Analytics 4) from Cloudflare as well. This way it might be easier to set up a minimal example.
Thanks for the debug log. That shows the page being generated. Do you see it serving the cached file? It should look something like this but might differ depending on your configuration.
Does the debug log show cached pages being served when Google tag gateway is enabled?
wpsc_is_caching_user_disabled: false
ACCEPT: text/html
wp_cache_get_cookies_values: return:
supercache dir: ABSPATH/wp-content/cache/supercache/.....
wp_cache_get_cookies_values: return:
Fetched gzip static page data from supercache file using PHP. File: ABSPATH/wp-content/cache/supercache/....If you disable caching, does Google tag gateway still make your site slow?
It may well be that there’s something else on your site or how it interacts with Cloudflare perhaps, that’s making it slow.
For Zaraz I was able to fix the speed issues by deactivating “Auto-inject script: Automatically inject the Zaraz Initialization script into the page” in Cloudflare’s Zara settings and including the script myself in WordPress.
<script src="/cdn-cgi/zaraz/i.js" referrerpolicy="origin"></script>For some reason speed slows down significantly when Cloudflare “auto injects” some script. I think I am not able to dig deeper here. Maybe someone from Cloudflare’s team has to get involved.
A minimal setup is:
1. wordops + wpsc installation + cloudflare proxy
2. observe site speed (disabled browser cache)
3. activate Zaraz with Google Analytics 4 in Cloudflare
4. observe site speed (disabled browser cache)Even without wpsc caching site is slow with Google tag gateway. So probably unrelated to wpsc and a general speed issue at Cloudflare, as it does inject scripts on their side.
Hi @telcy,
Thank you for all the detailed testing and updates throughout this thread. Your findings have been thorough and valuable: it looks like the slowdown when activating Google Tag Gateway (or similar script injectors) is unrelated to WP Super Cache and likely derives from how Cloudflare is injecting or routing the script.
Since this behaviour falls outside the core scope of the plugin, it would be best to pursue this further with Cloudflare support or the Google Tag Gateway team: they’ll be better positioned to help troubleshoot how script injection affects dynamic delivery on your stack.
Thanks again for sharing your progress, and wishing you smooth optimization moving forward!
The topic ‘Caching breaks when using Google tag gateway’ is closed to new replies.