Cloudflare Caching

chartung @chartung@community.nodebb.org

<p>To minimize load on our servers, I would like to set Cloudflare to cache as much of the content as possible.<br /> I'm assuming that any image files or anything with a css/js/json file extension is safe to cache.<br /> Obviously we can't cache html content for logged-in users, since there is user-specific data included in the headers.<br /> As far as I can tell, it should be safe to cache html content for guests as long as the TTL is short (guests cannot post on our site, if that's relevant). However, it's not clear how we can implement that. The <code>express.sid</code> cookie is set for guests, so we can't just cache when that cookie is absent. It should be possible to set a custom cookie on login and clear that cookie on logout, but I can't find anywhere to set that cookie. I'm using a fork of <a href="https://github.com/julianlam/nodebb-plugin-sso-oauth" rel="nofollow ugc">https://github.com/julianlam/nodebb-plugin-sso-oauth</a>, and the only place I can find a <code>res</code> object is <a href="https://github.com/julianlam/nodebb-plugin-sso-oauth/blob/master/library.js#L124" rel="nofollow ugc">https://github.com/julianlam/nodebb-plugin-sso-oauth/blob/master/library.js#L124</a>, but setting the cookie fails because <code>res.cookie</code> is undefined.</p> <p>Is there any way I can set a custom cookie on login, or ensure that NodeBB does not set an <code>express.sid</code> cookie for guests?</p>

Read more →
0
0

If you have a fediverse account, you can quote this note from your own instance. Search https://community.nodebb.org/post/104322 on your instance and quote it. (Note that quoting is not supported in Mastodon.)