# Custom Redirect Script Caching Old URL (Page/CDN Issue?)

**URL:** <https://community.hubspot.com/t/custom-redirect-script-caching-old-url-page-cdn-issue/143544>\
**Category:** CMS Development\
**Tags:** javascript, enterprise\
**Created:** [December 1, 2025, 4:55pm UTC](https://community.hubspot.com/t/custom-redirect-script-caching-old-url-page-cdn-issue/143544 "2025-12-01T16:55:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DJohnson4](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/djohnson4/32/92090_2.png) [@DJohnson4](https://community.hubspot.com/u/DJohnson4)\
**Post date:** [December 1, 2025, 4:55pm UTC](https://community.hubspot.com/t/custom-redirect-script-caching-old-url-page-cdn-issue/143544/1 "2025-12-01T16:55:29Z")

</div>

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**

```lia-code-sample
<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**

1. Has anyone experienced HubSpot stubbornly caching old code in the page header after multiple re-publishes?
2. 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

---

<div class="post-metadata">

**Author:** ![STierney](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stierney/32/186066_2.png) [@STierney](https://community.hubspot.com/u/STierney)\
**Post date:** [December 1, 2025, 9:42pm UTC](https://community.hubspot.com/t/custom-redirect-script-caching-old-url-page-cdn-issue/143544/2 "2025-12-01T21:42:43Z")

</div>

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](https://community.hubspot.com/t5/user/viewprofilepage/user-id/9259), @ashleyidesign, and @Bryantworks - any thoughts on this setup for @DJohnson4?  
Shane, Senior Community Moderator

---

<div class="post-metadata">

**Author:** ![Mike\_Eastwood](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mike_eastwood/32/70075_2.png) [@Mike\_Eastwood](https://community.hubspot.com/u/Mike_Eastwood)\
**Post date:** [December 3, 2025, 8:23pm UTC](https://community.hubspot.com/t/custom-redirect-script-caching-old-url-page-cdn-issue/143544/3 "2025-12-03T20:23:37Z")

</div>

Hi @DJohnson4

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.

Have fun

Mike

p.s. thank you for the mention @STierney

Here to learn more about HubSpot and share my HubSpot Knowledge. I’m the founder of [Webalite](https://www.webalite.com?utm_campaign=community-forum&utm_source=community&utm_content=signature) a Gold HubSpot Partner Agency based in Wellington, New Zealand and the founder of **Portal-iQ** the world’s first automated [HubSpot Portal Audit](https://portal-iq.com?utm_campaign=community-forum&utm_source=community-forum&utm_content=signature) that helps you work smarter with HubSpot.

---

<div class="post-metadata">

**Author:** ![BrandonWoodruff](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/brandonwoodruff/32/61045_2.png) [@BrandonWoodruff](https://community.hubspot.com/u/BrandonWoodruff)\
**Post date:** [December 2, 2025, 2:54pm UTC](https://community.hubspot.com/t/custom-redirect-script-caching-old-url-page-cdn-issue/143544/4 "2025-12-02T14:54:58Z")

</div>

Hi David,

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 by **marking it as a solution.**

| ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/3/d314478a36473977ed45320812b9331d25e0d3c4.jpeg) | **[Brandon Woodruff](https://www.linkedin.com/in/brandon-woody-woodruff/)**  
Senior Software Developer @ [Pearagon](https://www.pearagon.com/)Still have questions? Reach out at [brandon@pearagon.com](mailto:brandon@pearagon.com) ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/c/dcad77e6cf96145dd117147531ae4423b9b5cd91.png) |

* * *
