Skip to content

Conversation

@wizardlyhel
Copy link

@wizardlyhel wizardlyhel commented May 5, 2022

Description

Get cache to store full page response

This PR contains a couple fixes:

  • Sub queries was not revalidating properly

Before submitting the PR, please make sure you do the following:

  • Read the Contributing Guidelines
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123)
  • Update docs in this repository according to your change
  • Run yarn changeset add if this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning

@github-actions github-actions bot had a problem deploying to preview May 12, 2022 16:23 Failure
@github-actions github-actions bot had a problem deploying to preview May 12, 2022 16:49 Failure
@github-actions github-actions bot had a problem deploying to preview May 12, 2022 18:35 Failure
@github-actions github-actions bot had a problem deploying to preview May 12, 2022 18:45 Failure
@github-actions github-actions bot had a problem deploying to preview May 12, 2022 19:11 Failure
@wizardlyhel wizardlyhel marked this pull request as ready for review May 12, 2022 19:12
@github-actions

This comment has been minimized.

@mcvinci
Copy link
Contributor

mcvinci commented May 13, 2022

@wizardlyhel
Copy link
Author

@mcvinci No change to doc - this will work magically on its own with the existing caching options. I might need to add new helper functions later. I'll let you know if there are any doc updates.

@github-actions github-actions bot had a problem deploying to preview May 13, 2022 21:37 Failure
@github-actions github-actions bot had a problem deploying to preview May 16, 2022 21:57 Failure
@wizardlyhel wizardlyhel changed the title Full page cache cache-control and stale-while-revalidate fixes May 17, 2022
@wizardlyhel
Copy link
Author

Full page caching feature moved to Shopify/hydrogen#1294

Copy link
Contributor

@jplhomer jplhomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and questions. Nice work catching all the bugs!


const streamer = rscWriter.renderToPipeableStream(AppRSC);
response.writeHead(200, 'ok', {
'cache-control': componentResponse.cacheControlHeader,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're not writing any value for cache-control 🤔 where does the cache header (default and specific) get written?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is being set inside ServerComponentResponse.cache

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually nvm - I was wrong

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took this fix (that didn't fix) out of this PR

Comment on lines +121 to +123
CacheSeconds({
maxAge: 10,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we setting a maxAge + SWR for the cache lock?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the key needs to be valid (so that it stays in cache), so that future cache.get attempts on revalidating the same key (while a revalidation of the same key is in progress) will get a HIT response

Copy link
Contributor

@jplhomer jplhomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@wizardlyhel wizardlyhel merged commit 771786a into v1.x-2022-07 May 18, 2022
@wizardlyhel wizardlyhel deleted the full-page-cache branch May 18, 2022 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants