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

feat(query): fully cacheable api #1752

Merged
merged 1 commit into from Dec 15, 2022
Merged

feat(query): fully cacheable api #1752

merged 1 commit into from Dec 15, 2022

Conversation

farnabaz
Copy link
Member

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link

netlify bot commented Dec 14, 2022

βœ… Deploy Preview for nuxt-content ready!

Name Link
πŸ”¨ Latest commit b46eaf2
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/639a08fd4773de0009691d99
😎 Deploy Preview https://deploy-preview-1752--nuxt-content.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@farnabaz
Copy link
Member Author

Merging to test on edge

@farnabaz farnabaz merged commit 0683ade into main Dec 15, 2022
@farnabaz farnabaz deleted the feat/api-param-as-path branch December 15, 2022 10:59
@farnabaz farnabaz mentioned this pull request Dec 15, 2022
@@ -37,7 +37,7 @@ export const createQueryFetch = <T = ParsedContent>(path?: string) => async (que

const params = query.params()

const apiPath = withContentBase(process.dev ? '/query' : `/query/${hash(params)}.${content.integrity}.json`)
const apiPath = withContentBase(`/query/${process.dev ? '_' : `${hash(params)}.${content.integrity}`}/${encodeQueryParams(params)}.json`)
Copy link
Member

Choose a reason for hiding this comment

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

Important note: This is potentially a breaking change as Nitro v1 limits whole URL length to 250 and by this change, we cause to skip such routes when prerendering.

https://github.com/unjs/nitro/blob/cbcd0681d37839f93fc7f3f106d34e3f01d2ac84/src/prerender.ts#L83

This change could be behind an experimental flag until the release of Nuxt 3.1 and Nitro 2

Copy link
Member

Choose a reason for hiding this comment

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

Also, this change causes slight performance overhead of long URLs which is mainly needed for hybrid/server mode. When _generate: true flag exists, we can safe assume deployment is full-static and omit last segment.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

So what you are suggesting is that we should switch between these methods based on nuxt.options._generate boolean.
Pass this option to the runtimeconfig to delect whether its generated or not and change the API fetch.

Right?
@pi0

Copy link
Member Author

Choose a reason for hiding this comment

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

Personally, I don't like to create complicated behavior for us to describe and for users to understand.
So I'll go with experimental flag and disable this feature by default.

Copy link
Member

@pi0 pi0 Dec 15, 2022

Choose a reason for hiding this comment

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

That should work yes. We also need to have it as an experimental opt-in flag like content.experimental.fullPath since as mentioned above, this feature, needs to be coupled with nitro v2 fix for long path segments support.

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.

None yet

2 participants