diff --git a/lib/composables/preview.spec.ts b/lib/composables/preview.spec.ts index a8a110238..85ce96dfb 100644 --- a/lib/composables/preview.spec.ts +++ b/lib/composables/preview.spec.ts @@ -67,6 +67,18 @@ describe('preview composable', () => { expect(wrapper.text()).toMatch('/core/preview?fileId=2') }) + it('uses etag for cache busting', () => { + const previewNode = new File({ + ...createData('tst.txt', 'text/plain'), + attributes: { + etag: 'the-etag', + }, + }) + + const { previewURL } = usePreviewURL(previewNode) + expect(previewURL.value?.searchParams.get('c')).toBe('the-etag') + }) + it('uses Nodes previewUrl if available', () => { const previewNode = new File({ ...createData('text.txt', 'text/plain'), diff --git a/lib/composables/preview.ts b/lib/composables/preview.ts index 90c69cb61..dba8d6202 100644 --- a/lib/composables/preview.ts +++ b/lib/composables/preview.ts @@ -73,6 +73,9 @@ export function getPreviewURL(node: Node, options: PreviewOptions = {}) { // Handle cropping url.searchParams.set('a', options.cropPreview === true ? '0' : '1') + + // cache busting + url.searchParams.set('c', `${node.attributes.etag}`) return url } catch (e) { return null