-
Notifications
You must be signed in to change notification settings - Fork 3
feat(chore): add default versioning & hostname on cache key #2
base: main
Are you sure you want to change the base?
feat(chore): add default versioning & hostname on cache key #2
Conversation
Hi @bloodf, is it possible to validate this MR please? |
This is a great contribution, but I have some issues with the proposed approach. Besides the breaking change caused by moving the Redis client configuration to the
I think that it's much easier to add cache invalidation as part of the deployment process. As described in the documentation, you can invalidate the whole cache by making a request like this:
Let me know what you think about this because I might be wrong. |
Yes i see, i will remove it. By default it will be empty, we should warn the users in the documentation for this part. What do you think ?
I think for this part we will have to let the developers do what they want to do. What advertises a problem when I was working on VSF1 with many items being deleted at once caused a problem with Redis when deploying. |
After thinking about this more, I changed my mind and agree with your approach.
I will submit a code suggestion to improve DX and avoid breaking changes. I'd like you to update this document to include information about the new property ( |
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.
Please test these changes before merging
src/index.js
Outdated
|
||
export default function RedisCache (options) { | ||
const client = new Redis(options.redisConfig); |
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.
const client = new Redis(options.redisConfig); | |
const { version, ...redisConfig } = options; | |
const client = new Redis(redisConfig); | |
const fallbackVersion = crypto.randomBytes(15).toString('hex'); | |
if (!version) { | |
Logger.warn('The `version` property is missing in the `@vue-storefront/redis-cache` package configuration. In a multi-instance setup, this will result in a separate cache for every instance. Please refer to Redis driver documentation for more details.'); | |
} |
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.
Done
src/index.js
Outdated
const defaultVersion = crypto.randomBytes(15).toString('hex') | ||
|
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.
const defaultVersion = crypto.randomBytes(15).toString('hex') |
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.
Done
src/index.js
Outdated
const version = options.version || defaultVersion | ||
const hostname = context.req.hostname |
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.
const version = options.version || defaultVersion | |
const hostname = context.req.hostname | |
const version = options.version || fallbackVersion; | |
const hostname = context.req.hostname; |
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.
Done
678ffd6
to
4c691ec
Compare
Update change for this MR vuestorefront/redis-driver#2
@filipsobol for the documentation vuestorefront/vue-storefront#6666 |
Description
Added hostname and a new configuration to set a version or a default one generated at build time.
Related Issue
Motivation and Context
Currently, we are missing some functionality to be able to use the SSR cache correctly with our implementation of VSF (Magento2 integration).
Actually when a new version is deployed, we can get the old version from the cache and it can leverage multiple bugs on a deployment.
The other point is that we are using subdomain for our multistore, but the cache key is only used with the
route
value for example/
for the homepage. With that a page for a subdomain will be cache for every subdomain of the application.How Has This Been Tested?
Checked subdomain are cached separately.
Checked the keys format in redis.
Checked if a new key is created after a new build.
Screenshots (if appropriate):
Types of changes
Checklist: