CMS Development

BPatel1
Member

Loggin Cache Issue In Blog and CMS

SOLVE

Hi,

 

We've integrated login & register feature in Hubspot CMS using this g.com/_hcms/mem/login and session is working properly and getting all the data in CMS template.

We are using request_contact.is_logged_in to check the same but this is not working in blogs. Sometimes it's working sometime not. Also, not able to get the contact properties as well. Same sometime it works sometime now. Also, date parameters like now() not working in blog templates.

Any ideas or solution?
 

1 Accepted solution
RubenBurdin
Solution
Top Contributor

Loggin Cache Issue In Blog and CMS

SOLVE

@BPatel1  totally fair question and yeah, you’re right to be cautious if you’re dealing with paid or gated content.

So here’s how it works: even though blog pages are heavily cached, HubSpot’s default page restriction feature (the one you apply via the content settings UI) still works because it runs at a server level before the page is served.

Basically, it’s a middleware layer that checks the visitor’s membership/session before it hands over the cached HTML. So while you can’t rely on request_contact.is_logged_in inside the template (because that part can get cached), the restriction logic itself is enforced outside the template — and that's why protected blog pages can’t be accessed by someone who’s not logged in, even if the page is cached.

That part’s secure. So yeah — if you're actually using HubSpot's native membership restrictions (via the "Access control" setting on blog posts or listings), you’re good. The caching doesn't compromise that — just the ability to personalize content within the page.

In your case, since this is paid content, I’d stick with server-side membership enforcement and skip the client-side JS tricks unless it’s for non-sensitive personalization like “Hi [name]”. 

Hope it helps.

RubenB_0-1745106302148.png

Ruben Burdin 

Real-Time Data Sync Between any CRM or Database | Founder @Stacksync (YC W24) 



Did my answer help? Please mark it as a solution to help others find it too.

Ruben Burdin Ruben Burdin
HubSpot Advisor
Founder @ Stacksync
Real-Time Data Sync between any CRM and Database
Stacksync Banner

View solution in original post

0 Upvotes
3 Replies 3
RubenBurdin
Solution
Top Contributor

Loggin Cache Issue In Blog and CMS

SOLVE

@BPatel1  totally fair question and yeah, you’re right to be cautious if you’re dealing with paid or gated content.

So here’s how it works: even though blog pages are heavily cached, HubSpot’s default page restriction feature (the one you apply via the content settings UI) still works because it runs at a server level before the page is served.

Basically, it’s a middleware layer that checks the visitor’s membership/session before it hands over the cached HTML. So while you can’t rely on request_contact.is_logged_in inside the template (because that part can get cached), the restriction logic itself is enforced outside the template — and that's why protected blog pages can’t be accessed by someone who’s not logged in, even if the page is cached.

That part’s secure. So yeah — if you're actually using HubSpot's native membership restrictions (via the "Access control" setting on blog posts or listings), you’re good. The caching doesn't compromise that — just the ability to personalize content within the page.

In your case, since this is paid content, I’d stick with server-side membership enforcement and skip the client-side JS tricks unless it’s for non-sensitive personalization like “Hi [name]”. 

Hope it helps.

RubenB_0-1745106302148.png

Ruben Burdin 

Real-Time Data Sync Between any CRM or Database | Founder @Stacksync (YC W24) 



Did my answer help? Please mark it as a solution to help others find it too.

Ruben Burdin Ruben Burdin
HubSpot Advisor
Founder @ Stacksync
Real-Time Data Sync between any CRM and Database
Stacksync Banner
0 Upvotes
RubenBurdin
Top Contributor

Loggin Cache Issue In Blog and CMS

SOLVE

Hi @BPatel1 

What you’re running into is that blog posts and blog listing pages are cached more aggressively than standard CMS pages — which is why things like request_contact.is_logged_in, now(), and contact properties can feel super unreliable on them. Sometimes you hit a fresh version and everything works... and then five minutes later it doesn’t.

Best workaround I’ve seen is to move any login-aware logic to the client side.

Basically, you set up a little serverless function in HubSpot that returns something like { isLoggedIn: true, firstname: 'Sarah' } and then use JavaScript on the blog template to fetch that and adjust what the user sees (show/hide sections, name, etc).

It adds a tiny bit of complexity, but it’s way more reliable than relying on the server to guess who’s logged in on a cached page.

If that’s too heavy right now, you could start with just showing a "manage account" link or something generic and skipping personalization until you're ready to handle it with JS + functions.

But yeah — I’d avoid trying to force login-based content directly into the blog templates. The caching will keep making it inconsistent.

Hope it helps.

RubenB_0-1744951380316.png

Ruben Burdin 

Real-Time Data Sync Between any CRM or Database | Founder @Stacksync (YC W24) 

Did my answer help? Please mark it as a solution to help others find it too.

Ruben Burdin Ruben Burdin
HubSpot Advisor
Founder @ Stacksync
Real-Time Data Sync between any CRM and Database
Stacksync Banner
0 Upvotes
BPatel1
Member

Loggin Cache Issue In Blog and CMS

SOLVE

Thanks for your quick reply.

If Blog pages are fully cached then how Hubspot default page restiction is working? 

Are they doing server side checking or something?

We can't do server less concept here as we'll have paid content so it'll be risky if we do client side restrictions using javascript.

0 Upvotes