ProjectEvergreen / greenwood

Greenwood is your workbench for the web, embracing web standards from the ground up to empower your stack from front to back.
https://www.greenwoodjs.io
MIT License
96 stars 9 forks source link

browsers inconsistently serving incorrect / stale content from dev server #1108

Closed thescientist13 closed 1 year ago

thescientist13 commented 1 year ago

Type of Change

Bug

Summary

Related to the recent v0.28.0 release, it seems that browsers, in particular when switching projects that might run on the same port, load incorrect / stale data. The only sure fire way to avoid this issue is to make sure cache is disabled in your browsers network tab while having it open.

https://github.com/ProjectEvergreen/greenwood/assets/895923/6a2b57a6-1fc0-4163-8682-3ee5d2dd65d4

I know others like @aholtzman have seen similar issues where content changes / reloads do not seem to take effect unless the browser console / dev tools are open.

Details

In theory Greenwood should be helping to mitigate this using ETag caching headers but there's a good chance the implementation was not sufficiently updated enough after the Web API standardization overhaul that occurred as part of that release.

My suspicion lies here, where we still treat the response body as a string, but post refactor, it is now a ReadableStream

const etagHash = url.pathname.split('.').pop() === 'json'
  ? hashString(JSON.stringify(body))
  : hashString(body);

So I think it is just coming out as '[object Object]' each time?