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

Update Fetch Requests to Handle Caching in Next 15 #1300

Closed
wants to merge 8 commits into from

Conversation

nishant2253
Copy link

📚 Description

This codemod refactors fetch requests in your code to handle caching according to the new default behaviors in Next.js. By default, fetch requests are no longer cached. This codemod updates fetch requests to include the cache option for specific requests or adds fetchCache to layouts or pages for global caching control.

1.Find Fetch Requests: Identifies fetch requests in the code that require caching adjustments.
2. Property Check: Ensures fetch requests are updated with the appropriate cache option where necessary and adds the fetchCache option for global caching control.
3.Add Caching Configuration: Inserts export const fetchCache = 'default-cache'; in layouts or pages to apply default caching for all fetch requests unless overridden.
4. Clean Up: Removes the experimental object if it is empty after the migration.

To run this codemod, run the following command in the project directory:
codemod Next/15/Update-Fetch-Requests-to-Handle-Caching

🧪 Test Plan

Test the codemod by applying it to a specified repository to ensure fetch requests and layout files are correctly updated for caching behavior. Verify that fetch requests are correctly modified to include the cache option and that global caching settings are applied correctly with export const fetchCache = 'default-cache';.

  • Apply the codemod to the repository available at (https://github.com/imbhargav5/nextbase-nextjs-supabase-starter) and (https://github.com/nisabmohd/ChatGPT).

  • Confirm that all fetch requests are updated with appropriate caching options (cache or fetchCache).

  • Test the application to ensure that it functions correctly with the updated fetch caching settings.

    All other test cases are run in the codemod studio and are present in /codemod/packages/codemods/next/15/fetch-request-caching/textfixtures/.

📄 Documentation to Update

  • If applicable, update any relevant documentation to reflect changes in caching behavior for fetch requests. This may include README files or other developer guides that reference fetch request caching strategies.s.

Copy link

vercel bot commented Aug 30, 2024

@nishant2253 is attempting to deploy a commit to the Codemod Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Aug 30, 2024

CLA assistant check
All committers have signed the CLA.

@mohab-sameh
Copy link
Contributor

merge into one PR

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