This repository was archived by the owner on May 28, 2023. It is now read-only.
Varnish Cache with auto invalidation for ES #408
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello.
I've just prepared a Varnish configuration with autoinvalidating ES. It is able to really improve your page's speed.
Request to the:
Without Varnish (132ms):


With Varnish (79ms):
Elasticsearch is pretty good at caching. However, let's look at extensions that fetch some data from a real backend (M2). Example of my extension that fetches menu without Varnish (791ms):

As you see TTFB is really huge. It is because API sends the request to Magento. So normally it goes through VSF-API -> Magento. When we use Varnish we cache it in front of the VSF-API so the response is... a bit faster! (84ms)

I am also wondering about caching
Pull Cart requestand invalidate it withUpdate & Delete. I have to check this idea.Inside my PR, we have file
docker/varnish/README.mdthere you can find every information I've prepared for developers.https://github.com/DivanteLtd/vue-storefront-api/blob/342fe2b89ad895578cb2d9fdfdb62cffa20f6231/docker/varnish/README.md
As we have a docker image, we can easily test it locally. We just need to create the same network for each docker-compose. Usually, I run:
Then, in another terminal I run:
So when I am experimenting with Varnish's config, I have only to rerun Varnish.
Error or tagless requests should not be cached.