Skip to content
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

fix(build): cache key should consider file path #948

Merged
merged 1 commit into from
Jul 8, 2022

Conversation

fi3ework
Copy link
Contributor

@fi3ework fi3ework commented Jul 8, 2022

fix #947

@brc-dd
Copy link
Member

brc-dd commented Jul 8, 2022

IMO just setting cacheKey to this would work:

const cacheKey = cache.get(JSON.stringify({ src, file }))

There is no need for complex functions as src and file are strings and their order will always be same if the code is written like this. So stringifying {src, file} should yield same result every time if the content is unchanged.

@brc-dd brc-dd changed the title fix: cache key should consider file path fix(build): cache key should consider file path Jul 8, 2022
@brc-dd
Copy link
Member

brc-dd commented Jul 8, 2022

I have a doubt too. What would be the need of caching then? file cannot be same for two files. Will there ever be a hit?

@fi3ework
Copy link
Contributor Author

fi3ework commented Jul 8, 2022

I though node.js's JSON. stringify was not stable, but it does. So yes, we do not need the hash function anymore.

@fi3ework
Copy link
Contributor Author

fi3ework commented Jul 8, 2022

I have a doubt too. What would be the need of caching then? file cannot be same for two files. Will there ever be a hit?

AFAIK, the cache will be hit in handleHotUpdate stage if you're modifying the content the same as some cached content.

@brc-dd
Copy link
Member

brc-dd commented Jul 8, 2022

AFAIK, the cache will be hit in handleHotUpdate stage if you're modifying the content the same as some cached content.

Okay, I tested with debug, every markdown file is rendered twice during build, so setting cache reduces nearly half the time. It is still being triggered. And in dev server, a cache hit occurs if you change some content, save it, then undo the changes and then save it.

@brc-dd brc-dd merged commit 1daeaa1 into vuejs:main Jul 8, 2022
@brc-dd
Copy link
Member

brc-dd commented Jul 8, 2022

Thanks for the PR!

@fi3ework fi3ework deleted the fix-947 branch July 8, 2022 14:18
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can not navigate of pages with same content
2 participants