-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add caching #54
Add caching #54
Conversation
Uses the jsonapi-serializer feature for caching that uses the configured Rails cache store. Never expire the records because page and element records have a cache_key that is updated by alchemy in the correct way.
04d6cf5
to
1915ab4
Compare
I think the Alchemy branch this references needs to be changed to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works really well, I couldn't break it.
Here's what I tried:
For both index and show actions:
Load page -> 200
Load it again -> 304
Change it -> 304 (page not published!)
Publish it -> 200
Load it again -> 304
Change params -> 200
Load it again with changed params -> 304
The internet is great.
Thanks. Have you tried the admin and layoutpages routes as well?
Yay, HTTP Caching. Take that GraphQL |
Prevents the database from loading all content if the page is still fresh and the browser can use its cache
Only loads pages and all includes if the page is stale, otherwise it returns a 304 calculated by the latest published page published_at value.
If we want to be able to use CDNs we need to set public cache headers and a expiration duration. The expiration defaults to 3 hours but you can set a ALCHEMY_JSON_API_CACHE_DURATION variable to any integer.
4d6f938
to
eb8b7ce
Compare
Uses the jsonapi-serializer feature for caching that uses the configured Rails cache store.
Never expire the records because page and element records have a cache_key that is updated by alchemy in the correct way.
Uses conditional get for loading page(s) only when necessary from the database. If the browser cache is still fresh we return a 304 instead.