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!
Thanks,
David

