exhibitionist-digital / ultra

Zero-Legacy Deno/React Suspense SSR Framework
https://ultrajs.dev
MIT License
2.99k stars 65 forks source link

No cache busting? #268

Closed sjc5 closed 1 year ago

sjc5 commented 1 year ago

Hi there, wonderful project!

I am noticing that all my client modules are cached as public, max-age=31536000, immutable and have no hash or anything associated with the file names. It requires a hard reload (with browser cache disabled) to get latest version of the client modules.

Am I likely doing something dumb to have caused this not to work as you'd expect? To be clear, I would expect these assets to include content hashes in their filenames, or similar, so it would download a fresh copy when the code changes.

If this is something that we need to do manually with this framework, any recommendations on approach?

Thanks very much! Sam

b3nten commented 1 year ago

Are you noticing this in production with a build, or in dev?

sjc5 commented 1 year ago

Hi @B3nten. I'm noticing it in a production environment (Deno Deploy).

sjc5 commented 1 year ago

It looks like this was due to using a custom file structure.

Instead of:

- ROOT:
  - server.tsx (server entry)
  - client.tsx (client entry)
  - src/
    ...stuff

I was doing:

- ROOT:
  - server/
    - index.tsx (server entry)
      ...stuff
  - client
    - index.tsx (client entry)
      ...stuff

Upon switching back to the file structure instantiated by the CLI, the files are indeed getting hashes appended. It would be preferred if the build tool didn't make assumptions around file structure (or at least if they were more explicit), but I'll go ahead and close.

Thanks!

deckchairlabs commented 1 year ago

It looks like this was due to using a custom file structure.

Instead of:

- ROOT:
  - server.tsx (server entry)
  - client.tsx (client entry)
  - src/
    ...stuff

I was doing:

- ROOT:
  - server/
    - index.tsx (server entry)
      ...stuff
  - client
    - index.tsx (client entry)
      ...stuff

Upon switching back to the file structure instantiated by the CLI, the files are indeed getting hashes appended. It would be preferred if the build tool didn't make assumptions around file structure (or at least if they were more explicit), but I'll go ahead and close.

Thanks!

Yes we default to hashing assets within src and public although those entry points should be included as hash targets, so probably worth opening a separate issue, as that is a bug!