'Disable nextjs page caching for certain dynamic routes

We have the following paths which is generated with the same [...brand].tsx.

  • /Brand (only cache this)
  • /Brand/Y
  • /Brand/X

We only want nextjs to cache the first one. However now nextjs is caching all sub urls, meaning links such as /Brand/X?bing=etc gets cached as well and taking up a lot of space. How can we disable next for saving the generated files to disk via getStaticPaths or getStaticProps?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source