CMS Development

JHu
Member | Diamond Partner
Member | Diamond Partner

How to bust cache in module

My module needs to generate unique HTML output for each request, it has been working fine with a read from `request.cookies` which busts page cache, until a few weeks ago. Now the pages only generate new HTML when query string is changed. I have tried following tricks without success:

* {{ request.cookies.x }}

* {{ request.geoip_city }}

* {{ request.headers.*** }}

* {{ request.contact.email }}

* {{ local_dt }}

(and some others that I may not remember)

 

Is there any other way I can use to ensure the page is not cached? Thanks! FWIW my portal ID is 575821.

0 Upvotes
6 Replies 6
JHu
Member | Diamond Partner
Member | Diamond Partner

How to bust cache in module

@jmclarenAny update? 🙂

0 Upvotes
jmclaren
HubSpot Employee
HubSpot Employee

How to bust cache in module

Hey @JHu , what is it your module actually doing that the HTML is not being refreshed each request?

We'd rather you not resort to tricks to trigger caching to not work, and just make the end result work, or propose a better practice.

If you can share your Design Manager link to your module that would be really helpful. Please send that either as a DM on the community here, or if you're in the developer slack, DM it to `@jon mclaren` (that's me). I likely will respond faster if sent by Slack but it's your preference.

Jon McLaren

Sr. CMS Developer Advocate

Get started developing on the HubSpot CMS Developer Changelog
How to optimize your CMS Hub site for speed

If my reply answered your question, please mark it as a solution, to make it easier for others to find.

ROy5
Member

How to bust cache in module

Not to drop into this old post, but I think my post is best fit here rather than another new one. I find this one of the most annoying parts of deploying to Hubspot (Otherwise it's pretty ok).  I have several clients of I have created sites for, and when debugging and updating small design issues, sometimes those changes don't show up. Sometimes, I wait overnight and the issues are still there.  I have to constantly second guess if I am editing the wrong file and such.
Ideally, I could see cache on by default, and an option if hs watch that could disable cache while hs watch is on (or times out after a few minutes).

0 Upvotes
JHu
Member | Diamond Partner
Member | Diamond Partner

How to bust cache in module

@jmclarenThanks for your reply, the module is at https://app.hubspot.com/design-manager/575821/modules/28948434330 and you can test it at https://offers.techimpact.org/training/google-analytics . We are generating an one-time token as security measure for calling a custom integration, the token contains timestamp and supposed to change on each request, and a signature generated in HubL. The timestamp is there to avoid the token being reused, and since it is signed it is not possible to change it on client side.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

How to bust cache in module

Hi @JHu 

Welcome to the Community!

If you go to the variables doc and do a search for Use of this variable will disable page caching, you should see all variables that should break a page's cache. 

0 Upvotes
JHu
Member | Diamond Partner
Member | Diamond Partner

How to bust cache in module

Hi @dennisedson , thanks for your reply, I actually tried most of them before, but I just tried all of them again and none worked. Any idea?

0 Upvotes