Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Implement support for cached-fetches#132

Merged
skx merged 6 commits intomasterfrom
131-cache
Jun 4, 2024
Merged

Implement support for cached-fetches#132
skx merged 6 commits intomasterfrom
131-cache

Conversation

@skx
Copy link
Copy Markdown
Owner

@skx skx commented Jun 1, 2024

This pull-request, once complete, will close #131 by avoiding the need to process remote feeds which have not changed since their last fetch.

We do this by retrieving "Etag" and "Last-Modified" headers when a URL (i.e. feed) is fetched the first time, and use those values in subsequent fetches via headers ("If-Non-Matche", and "If-Modified-Since").

If the remote feed has not changed we should get a 3xx HTTP-status code, and the remote server should be greatful that it has less work to do.

This pull-request, once complete, will close #131 by avoiding the
need to process remote feeds which have not changed since their last
fetch.

We do this by retrieving "Etag" and "Last-Modified" headers when a
URL (i.e. feed) is fetched the first time, and use those values in
subsequent fetches via headers ("If-Non-Matche", and "If-Modified-Since").

If the remote feed has not changed we should get a 3xx HTTP-status
code, and the remote server should be greatful that it has less work
to do.
@skx
Copy link
Copy Markdown
Owner Author

skx commented Jun 1, 2024

Initial attempt seems reasonable. I get sensible responses - via the hardcoded fmt.Printf output. I need to run it a few days and see if stuff still works.

Sample output I see on curated feeds now:

First fetch:

Storing in cache: {W/"605f6913-9b6f1" }
HTTP fetch returned 200 OK:200

Second fetch:

We have a cached value from a previous fetch!
Setting cache headers for our outgoing request
Storing in cache: {W/"605f6913-9b6f1" }
Unchanged!

@skx skx merged commit 5b091af into master Jun 4, 2024
@skx skx deleted the 131-cache branch June 4, 2024 18:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ETag / If-Not-Modified headers

1 participant