Skip to content

Commit

Permalink
Setting both etag and modified-since fixes some
Browse files Browse the repository at this point in the history
eg mysql sources are 400MB and the cache hit wasn't working even though they send an etag. Setting the if modified since in addition to the etag fixed that. Now they return a 304.
  • Loading branch information
mxcl committed Apr 13, 2023
1 parent 6f6c26f commit 0e5d935
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</p>


# tea/cli 0.26.4
# tea/cli 0.27.0

`tea` puts the whole open source ecosystem at your fingertips:

Expand Down
5 changes: 4 additions & 1 deletion src/hooks/useDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ async function internal<T>({ src, headers, logger, dst }: DownloadOptions): Prom
headers ??= {}
if (etag_entry.isFile()) {
headers["If-None-Match"] = await etag_entry.read()
} else if (mtime_entry.isFile()) {
}
// sending both if we have them is ChatGPT recommended
// also this fixes getting the mysql.com sources, otherwise it redownloads 400MB every time!
if (mtime_entry.isFile()) {
headers["If-Modified-Since"] = await mtime_entry.read()
}
logger.replace(teal('querying'))
Expand Down

0 comments on commit 0e5d935

Please sign in to comment.