-
Notifications
You must be signed in to change notification settings - Fork 168
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
Use django caching to improve TTFB #487
Comments
This is a great idea, thanks for adding it! Let me know if you're interested in working on it too and I can add you to the issue. |
What views would this be worth adding too? The default is 300 which is 5 minutes. Is this the timeout that we would want to use? Or would there be a preferred time. I’d be interested working on this as it sounds like a good suggestion. :) |
I'll give it to you then! As for views: All of them? I think they're all pretty cachable. As for time, you can probably do longer. Content doesn't change for the most part. Could probably be an hour to a day even. |
This issue has been inactive for 344 hours (14.33 days) and will be unassigned after 64 more hours (2.67 days). If you have questions, let @geekygirlsarah know by comment, email, or Twitter. If you are still working on this issue, that's fine. Please comment here to tell the bot to give you more time. |
@geekygirlsarah When trying to use the local memory caching with the following settings:
I am getting this, presumably being the queryset is being stored and not being able to be parsed out. I managed to get site wide caching (https://docs.djangoproject.com/en/4.1/topics/cache/#the-per-site-cache) working using the Please let me know if this works for you and I will raise a PR for it 😄 |
Uh... I'm not sure. I can look into it, but what's the default that's not a |
The default that isn't is https://docs.djangoproject.com/en/4.1/topics/cache/#local-memory-caching. That is the one which throws the error. It also says
The file based one would belong on the Heroku instance for it's lifecycle. Which if you use one instance and it creates another would cache on the first visit pointed to that new instance. (As far as I know). The other options are Redis, Memcached or Database caching as you mentioned which looks at though it would all go in one cache table. https://docs.djangoproject.com/en/4.1/topics/cache/#database-caching I'm not sure What do you think? |
@geekygirlsarah I've been thinking if it runs on one instance then File Based Caching might be okay for the per site caching. Or would you rather I looked into the database caching? I'm not familiar with the infrastructure of the app so I'm happy to follow your lead! 😄 |
Yeah, it runs on one instance, but that instance is destroyed after every PR added in. So like today it might get destroyed after 2-3 PRs that I merge in. During slower months, the cache would build up. During October, the file-based cache probably wouldn't help much. I am thinking the DB caching might make more sense. Local development uses SQLite, production uses Heroku. Either way, Django knows about the DB, so I think it's mostly a matter of asking Django to make the migration to make the right table, then set up the caching to store it there. |
This issue has been inactive for 346 hours (14.42 days) and will be unassigned after 62 more hours (2.58 days). If you have questions, please leave a comment, message @codethesaurus or @geekygirlsarah on Twitter, or email [email protected].If you are still working on this issue, that's fine. Please comment here to tell the bot to give you more time. |
Commenting as PR is still open. |
This issue has been inactive for 345 hours (14.38 days) and will be unassigned after 63 more hours (2.63 days). If you have questions, please leave a comment, message @codethesaurus or @geekygirlsarah on Twitter, or email [email protected].If you are still working on this issue, that's fine. Please comment here to tell the bot to give you more time. |
Commenting as PR is still open and I haven't tested it yet |
This issue has been inactive for 347 hours (14.46 days) and will be unassigned after 61 more hours (2.54 days). If you have questions, please leave a comment, message @codethesaurus or @geekygirlsarah on Twitter, or email [email protected].If you are still working on this issue, that's fine. Please comment here to tell the bot to give you more time. |
This issue has been inactive for 419 hours (17.46 days) and is past the limit of 408 hours (17.00 days) so is being unassigned.You’ve just been unassigned from this ticket due to inactivity – but feel free to pick it back up (or a new one!) in the future! Thank you for your interest in contributing to this project. |
I still haven't tested this. Oops. I should really do that... |
This issue has been inactive for 347 hours (14.46 days) and will be unassigned after 61 more hours (2.54 days). If you have questions, please leave a comment, message @codethesaurus or @geekygirlsarah on Twitter, or email [email protected].If you are still working on this issue, that's fine. Please comment here to tell the bot to give you more time. |
This is on my to-do list for this upcoming week, I swear! I even have it on my to-do list for my week off work! |
This issue has been inactive for 346 hours (14.42 days) and will be unassigned after 62 more hours (2.58 days). If you have questions, please leave a comment, message @codethesaurus or @geekygirlsarah on Twitter, or email [email protected].If you are still working on this issue, that's fine. Please comment here to tell the bot to give you more time. |
This issue has been inactive for 418 hours (17.42 days) and is past the limit of 408 hours (17.00 days) so is being unassigned.You’ve just been unassigned from this ticket due to inactivity – but feel free to pick it back up (or a new one!) in the future! Thank you for your interest in contributing to this project. |
Description
To improve Core Web Vitals, we can cache pages that aren't regularly updated using Django's caching. In Memory caching is available so you don't have to run up a redis server or anything.
https://docs.djangoproject.com/en/4.0/topics/cache/#local-memory-caching-1
Requirements
Set up caching config as per the docs above.
Make a decision on what views can be cached, and which pages shouldn't be.
How long should it cache in memory for?
The text was updated successfully, but these errors were encountered: