Add cache buster to Hubspot Hubl get_asset_url | HTML Code Copy
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:
Steps:
- In Design Manager file view, right click and select “Copy Public URL” of the file
- 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’) }}”> - 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:
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.