Add cache buster to Hubspot Hubl get_asset_url | HTML Code Copy

CR Rollyson
2 min readAug 21, 2020

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.

If you found this helpful, like > follow > share > comment.

CR Rollyson is a Digital User Experience & Web Manager for a S&P 500 Fintech company and is the COO of Side Role, a marketing team in Charlotte North Carolina partnering with In-house Teams & Agencies, Non-profits, and Start-Ups. Learn more about Side Role here.

--

--

CR Rollyson

UX & Web mgr for a S&P 500 Fintech & COO of Side Role, a marketing team partnering w In-house Teams & Agencies, Non-profits, & Start-Ups. https://siderole.com