Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit c73d441

Browse files
fix: do not download cached files (#643)
Fixes #566 To quickly sum up the issue discovered in #566, this works: - Save file with contents 'a' - Download file. Contents === 'a' - Save file with contents 'b' - Download file. Contents === 'b' 😄 But as soon as it's a public file, it doesn't work: - Save file with contents 'a' - Make file public - Download file. Contents === 'a' - Save file with contents 'b' - Download file. Contents === 'a' 😢 I believe what happens when the file is flipped to a public object, we then have to worry about caching. When you update the file, the upstream API's `generation` property is updated as well for the Object record. So far, I've found three solutions: - Ensure the file we download will not be cached (`Cache-Control: no-store`) - Set `Cache-Control: no-transform` on the file's metadata - Send the download API request with the latest `generation` in the query I went with the first, as it seems the least error-prone.
1 parent 519ba1b commit c73d441

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

src/file.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,7 @@ class File extends ServiceObject<File> {
11601160

11611161
const headers = {
11621162
'Accept-Encoding': 'gzip',
1163+
'Cache-Control': 'no-store'
11631164
} as r.Headers;
11641165

11651166
if (rangeRequest) {

test/file.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ describe('File', () => {
833833
uri: '',
834834
headers: {
835835
'Accept-Encoding': 'gzip',
836+
'Cache-Control': 'no-store',
836837
},
837838
qs: {
838839
alt: 'media',

0 commit comments

Comments
 (0)