Can I generate cached content on HS (page, global content)

RMarinov
Member

Is it possible to build a cached landing page on HS?
I want to have the ability  to update the cache whenever I need to.

OR

Is it possible to build cached content, like global  content or module?

0 Upvotes
7 Replies 7
dennisedson
Community Manager

Hey @RMarinov 

I am not quite clear on what you are asking.  Technically, once you publish your landing page, it is cached

Per this article in the developer docs:

 

Browser and Server Caching

Every time a visitor requests a page, their browser makes a complex string of requests. These requests hit various servers which make complex calculations and routes to serve visitors their files.

HubSpot automatically caches pages and files on both the server and browser level to ensure the quickest delivery of all page assets to your website visitors. When your page or any dependency of your page (such as a template or module) changes, we automatically expire the server caches for that page.

Server caching is especially effective for mobile website visitors and visitors outside the US where network latency is higher.

 

However, if you are talking about having a module that persist throughtout many pages, then a global module is what you are looking for.

 

 

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes
RMarinov
Member


Hello @dennisedson ,

Thank you for your reply.

We have a landing page "super-cool-page" on HS. On our super-cool-page we have added

1) Ajax requests to our third-party site, thereby updating content dynamically

2) Iframes, again requesting/comming from our thurd-party site.


Lets assume super-cool-page is heavily visited one. Yes HS probably will cache some static content, but the AJAX requests will still be issued every time the page loaded. Our third-party side will not benefit from the HS caching in this way. 
Thanksfully the content requested from our third-party side doesnt change very often (we update it roughly once per month). 
We hope that we could prepare cached snippets(probably global content modules in HS - you name it) for these iframes only when the data gets changed. And then when user visits the super-cool-page the iframe would not issue request, but render cached content. 

I hope you get the idea. 
Thanks ! 

0 Upvotes
dennisedson
Community Manager

Gotchy.

@kierana , how would you go about this 😀

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes
RMarinov
Member

Is this possible with the available HS technologies?

0 Upvotes
dennisedson
Community Manager

I cannot think of a way of how to do it with HubSpot specific tech.

@piersg , do you have any ideas?

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes
piersg
Key Advisor

Hi @dennisedson and @RMarinov. You could maybe run the AJAX as a serverless function, set it to run once a month, and then use the HubDB API to update (or cache, in other words) a HubDB with the AJAX data. Then use the HubDB on your page. It would be very roundabout 😛

 

The iframe isn't relevant. Caching is determined by the HTTP response headers sent by the site being iframed.

kierana
Contributor

How about looking into more of a push methodology?

 

Refactor the script to a work as a scheduled script which generates a static file (as @piersg suggested)  - and then upload to the file manager with public visibility (https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file) using one of the Hubspot client libraries (https://developers.hubspot.com/docs/api/client-libraries) or to HubDB (but be aware of rate limits)

 

You can then just fetch the static file, which is served via hubspot, but do make sure you change the files domain to your website (https://knowledge.hubspot.com/files/copy-and-update-the-url-of-files-uploaded-to-the-file-manager)