-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider enabling nginx caching #195
Comments
I've had a brief look at this previously, and had a look today. Looks like it works well. I had a MISS on the initial /communities and then a HIT immediately after. I've enabled caching multiple times in $jobs and there are so many edge cases that it's sometimes difficult to find them without very thorough testing. (Mind you, I wasn't able to ask the dev's to change/fix bad items/code so I'm sure we can get everything sorted). If we want to do this lets try a 1.4.0 release, after the dust settles on Lemmy 0.19.0. Tasks/Thoughts
|
Have any thoughts on how to achieve this? You hit the nail on the head with strange edge cases that are difficult to account for, which has been my main trepidation. |
Pictrs also sends cache-control headers, so there should be no problem.
Can you give any examples of potential edge cases? What I can say is that the logic for cache-control headers in Lemmy is really simple. If the request was made by an authenticated user it gets
This is completely irrelevant for cache-control headers. |
@ticoombs That should be fixed by LemmyNet/lemmy#4337 |
Any news on this? What would be the current blockers to enable this? How would alternative web UIs be affected? |
We could probably add this with the next lemmy release then. @poVoq or someone could do a PR to this repo to add those blocks above. |
Mainly it would be good if some instances could try it in production before we enable it by default. To check if there are problems like receiving stale data, cached data being served while logged in, or worst case private api responses being cached and served to other users. |
I use the above settings in production, and never noticed any issue. But my instance is only used by a handful of users, so I cannot be sure that any rare issues would have been noticed. |
I've tested this and it looks good. Shall make it into 1.5.0 |
There is one minor issue that I noticed for a while now, and that is when I visit the frontpage I am not logged in. As soon as I hit the Refresh button in the browser, I am logged in again (and stay logged in for the next hours without any problems). But when visiting the site the next day, I need to hit Refresh again. To be honest, I cannot say for certain that this behaviour is caused by the above Nginx config, as I also have Cloudflare caching that domain. So it could also be related to some setting in my Cloudflare configuration for the domain. But it might be worth keeping an eye on this, because this issue started appearing after I enabled the Nginx caching (and I was using the Cloudflare cache long before that). |
Lemmy now sends proper cache-control headers so that responses for unauthenticated users can be cached. This would help to reduce resource usage on the server. However it could also lead to weird issues like stale responses. I previously attempted to add caching in #75, but back then it was quite hacky as Lemmy didnt set cache-control.
You can enable nginx caching by adding the following at the top of config file:
And this next to
proxy_pass
:Caching is enabled on https://voyager.lemmy.ml/ so you can give it a try and look at x-cache-status header.
The text was updated successfully, but these errors were encountered: