Dec 1, 202511:55 AM - edited Dec 1, 202511:58 AM
Contributor
Hi,
I am facing a persistent issue where a custom JavaScript redirect I've placed on a HubSpot page seems to be caching or serving an old version of the script, despite clearing my local cache, testing on multiple devices, and re-publishing the page multiple times.
1. The Goal
The page receives traffic from a third-party validation platform. Based on URL parameters (&cancel, &abandon, or &save), I need to redirect the user to a specific destination page.
2. The Current Script
<script>
// Get the query string part of the URL (e.g., "?reference=...&cancel")
const queryString = window.location.search;
// Check for EITHER 'cancel' OR 'abandon'
if (queryString.includes('&cancel') || queryString.includes('&abandon')) {
// **Immediate redirect to the cancellation page.**
window.location.replace('https:[DOMAIN]/[CANCELLATION_PAGE_SLUG];
}
// Check for the 'save' parameter
else if (queryString.includes('&save')) {
// **Redirect to the homepage.**
window.location.replace('https:[DOMAIN]');
}
</script>
3. The Problem
When a user lands on the HubSpot page (e.g., with https://[DOMAIN]/[LANDING_PAGE]?reference=UK12345&abandon), they are being redirected to [OLD_INCORRECT_URL] instead of the current desired URL (https://[DOMAIN]/[CANCELLATION_PAGE_SLUG]).
have confirmed the script above is the only version on the page.
I have deleted the script, republished the page, added it back, and republished again.
I have tested on multiple browsers, devices, and Private/Incognito modes.
I suspect this is an issue with HubSpot's CDN/Page Caching serving a stale version of the page's HTML, or perhaps an older version of the custom code file itself.
4. Question
Has anyone experienced HubSpot stubbornly caching old code in the page header after multiple re-publishes?
Is there a specific mechanism or workaround to force a hard clear of a HubSpot page's CDN cache?
Any advice on forcing HubSpot to refresh the live page's code would be greatly appreciated!
I have definetely seen issues where the HubSpot Pages don't always update fully. Here are a couple of suggestions I would suggest trying:
- open the relevant code file in design manager, as well as any pages that reference it, make a tiny change, and republish the asset and the page - clone the page, publish the clone, and see if the clone functions as expected.
Let me know if this helps, or if you have any other questions!
✔️Was I able to help answer your question? Help the community bymarking it as a solution.
I agree with @BrandonWoodruff - I've oftenw orked on modules that haven't updated a page once the module is changed. So, I use the same "bump" that Brandon recommends. A text change on the page is enough (I use a double full stop so I can see the change, then remove the extra full stop).
Also, did you know you can append a url with "?hsCacheBuster=true" to speed up testing.
Here to learn more about HubSpot and share my HubSpot Knowledge. I'm the founder of Webalite a Gold HubSpot Partner Agency based in Wellington, New Zealand and the founder of Portal-iQ the world's first automated HubSpot Portal Audit that helps you work smarter with HubSpot.
I have definetely seen issues where the HubSpot Pages don't always update fully. Here are a couple of suggestions I would suggest trying:
- open the relevant code file in design manager, as well as any pages that reference it, make a tiny change, and republish the asset and the page - clone the page, publish the clone, and see if the clone functions as expected.
Let me know if this helps, or if you have any other questions!
✔️Was I able to help answer your question? Help the community bymarking it as a solution.
Hey @DJohnson4 - thanks for posting in the Community!
I'd like to tag in some experts who may have some context for us regarding this behavior, as well as potential workarounds! @Mike_Eastwood, @ashleyidesign, and @Bryantworks - any thoughts on this setup for @DJohnson4?
Shane, Senior Community Moderator
Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.
I agree with @BrandonWoodruff - I've oftenw orked on modules that haven't updated a page once the module is changed. So, I use the same "bump" that Brandon recommends. A text change on the page is enough (I use a double full stop so I can see the change, then remove the extra full stop).
Also, did you know you can append a url with "?hsCacheBuster=true" to speed up testing.
Here to learn more about HubSpot and share my HubSpot Knowledge. I'm the founder of Webalite a Gold HubSpot Partner Agency based in Wellington, New Zealand and the founder of Portal-iQ the world's first automated HubSpot Portal Audit that helps you work smarter with HubSpot.