serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

Caching js, woff, css in public directory

Open marcfielding1 opened this issue 2 years ago • 2 comments

Hey,

I have a need to implement a static site with routes augmented with nextjs.

Question on stackoverflow here: https://stackoverflow.com/questions/72147058/serverless-nextjs-will-not-cache-js-css-or-woff-in-public-directory

Caching works fine on everything else, but even with the below, it still won't cache. Any ideas please?

publicDirectoryCache:
      value: public, max-age=0, s-maxage=86400
      test: /\.(gif|jpe?g|png|txt|xml|css|js|woff)$/i

marcfielding1 avatar May 20 '22 09:05 marcfielding1

As a workaround I was thinking I could try just requireDir the css/woff/js from _app.js maybe?

marcfielding1 avatar May 20 '22 10:05 marcfielding1

Just an update for this, I've managed get it working by manually setting s3 cache setting after deployment and caching query params, some of the jquery libs and random other stuff have js query params.

Now this is still a valid question, why doesn't the above pattern set the cache for me I suppose, I'll have a dive into the code at some point this week but if anyone else has a plan?

marcfielding1 avatar May 24 '22 09:05 marcfielding1