Closed mroderick closed 2 years ago
Can you please add a unit test?
I've pushed a fixup
commit that contains a test to exercise the partials mechanism
If there are no further comments, then I'll rebase this to merge the fixup
commits into the first commit and we can merge this
While using
point-of-view
I discovered a bug in the cache key generation for partials.A minimal, reproducible test case has been created in https://github.com/mroderick/point-of-view-bug.
This PR fixes that bug.
Background
The cache key has to consider
page
,partials
andrequestedPath
to be usable. Ignoring any of these values will result in a key that is too broad, which will result in invalid cache hits.Note: because
requestedPath
is used for determining whether minification should be used on the content, it also has to be used in the cache key.As below
Before
Would result in a cache key of
/templates/index.mustache-Partials
, which completely ignores the partials and the requested pathIf the next request would use the same template with different partials, it would get the same cache key, and thus the partials from the first request.
After
Would result in a cache key of
/templates/index.mustache|content:/templates/some-partial.mustache|/some-path-Partials
, which clearly usespage
,partials
andrequestedPath
for generating the key.Checklist
npm run test
andnpm run benchmark