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

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

--

--

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

CR Rollyson

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