Add cache buster to Hubspot Hubl get_asset_url with unixtimestamp –with available CMS functions (2 minutes, level easy)

Hubspot has their cache collection down pretty tight. While it’s helpful, there are situations where busting is helpful – like retrieving rows from a HubDB using a combination of hubl and javascript.

Here is the code:

Add cache buster to Hubspot Hubl get_asset_url with unixtimestamp — CMS functions

Steps:

  1. In Design Manager file view, right click and select “Copy Public URL” of the file
  2. For javascript files, create a new script tag — add the Public URL as the src=””. For css files, create a new style tag — add the Public URL as the href=””):
    <script src=”{{ get_asset_url(‘/path-to-file.js’) }}”></script>
    <link href=”{{ get_asset_url(‘/path-to-file.css’) }}”>
  3. Append to Public URL after the closing parentheses:
    + ‘?’ + unixtimestamp()

Code Snippet:

{{ get_asset_url(‘/Templates/Custom/Page/path-to-file.js’) + ‘?’ + unixtimestamp() }}

On Success:

If successful, you can refresh in browser code view and see the timestamp update on page refresh:

Cachebuster Refresh 1
Cachebuster Refresh 2
Cachebuster Refresh 3

Visit https://developers.hubspot.com/docs/cms/hubl/functions for more info on available out-of-the-box functions.

Visit my portfolio website here: https://crrollyson.com
Enlist my experience design+development help here: https://siderole.com

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
CR Rollyson

Amazing father, decent husband, digital marketing user experience & web manager. Having a good time with good folks.