Skip to content

Fix stale browser views after restarting in another directory#70

Merged
chrishrb merged 1 commit into
chrishrb:mainfrom
starius:invalidate-stale-cache
Apr 15, 2026
Merged

Fix stale browser views after restarting in another directory#70
chrishrb merged 1 commit into
chrishrb:mainfrom
starius:invalidate-stale-cache

Conversation

@starius
Copy link
Copy Markdown
Contributor

@starius starius commented Apr 15, 2026

Directory listings were being served through Go's FileServer, which meant the browser could revalidate / with
If-Modified-Since and get a 304 Not Modified. When go-grip was restarted on the same host and port in a different folder, the browser could then reuse the previous run's HTML and show an old file list.

Refactor the server to use a local mux, mark directory listings and rendered markdown pages as non-cacheable, strip conditional cache validators before directory requests reach FileServer, and add regression tests for the directory, markdown, and regular file cases.

Directory listings were being served through Go's FileServer,
which meant the browser could revalidate / with
If-Modified-Since and get a 304 Not Modified. When
go-grip was restarted on the same host and port in a
different folder, the browser could then reuse the
previous run's HTML and show an old file list.

Refactor the server to use a local mux, mark directory
listings and rendered markdown pages as non-cacheable,
strip conditional cache validators before directory
requests reach FileServer, and add regression tests for
the directory, markdown, and regular file cases.
Copy link
Copy Markdown
Owner

@chrishrb chrishrb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@chrishrb chrishrb merged commit d50bfc7 into chrishrb:main Apr 15, 2026
2 checks passed
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.

2 participants