Skip to content

Commit

Permalink
Do not load files from cache (#6447) (#6494)
Browse files Browse the repository at this point in the history
* Do not load files from cache (#6447)

* Do not load files from cache

* changelog

* Workaround CORS issue until owncloud/core#40024 is merged and released

* Update changelog with further information on Cache-Control header

Co-authored-by: Diogo Castro <[email protected]>
Co-authored-by: Dominik Schmidt <[email protected]>
  • Loading branch information
3 people authored Apr 27, 2022
1 parent 96f6d06 commit 5fbfb78
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions changelog/unreleased/bugfix-do-not-load-from-cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Bugfix: Do not load files from cache

When apps (i.e Drawio) tried to load a file, the browser caches the request.
If the file was modified somewhere else and the browser reads the file and its
version from the cache, the content shown to the user is outdated and saving any
changes is impossible until the cache is properly cleared.
Thus we now ask the browser to never load files from its cache in apps.

In order to achieve that we send a `Cache-Control` header along with requests.
Unfortunately currently released ownCloud 10 versions do not accept that header
in cross site origin setups. If you run ownCloud Web on a different domain than
your ownCloud 10 instance, then you might need to add `Cache-Control` to the list
of allowed CORS headers:

`occ config:system:set cors.allowed-headers --type json --value '["cache-control"]'`

Please make sure you don't override previous values!


https://github.com/owncloud/web/pull/6447
https://github.com/owncloud/core/pull/40024
2 changes: 1 addition & 1 deletion packages/web-app-draw-io/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default {
})
},
load() {
this.getFileContents(this.filePath, { resolveWithResponseObject: true })
this.getFileContents(this.filePath)
.then((resp) => {
this.currentETag = resp.headers.ETag
this.$refs.drawIoEditor.contentWindow.postMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function useAppFileHandling(options: AppFileHandlingOptions): AppFileHand
} else {
return client.files.getFileContents(filePath, {
resolveWithResponseObject: true,
noCache: true,
...options
})
}
Expand Down
2 changes: 2 additions & 0 deletions tests/drone/setup-server-and-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ else
fi
php occ config:system:set sharing.federation.allowHttpFallback --value=true --type=bool
php occ config:system:set web.rewriteLinks --value=true
# Remove when https://github.com/owncloud/core/pull/40024 is merged and released
php occ config:system:set cors.allowed-headers --type json --value '["cache-control"]'
fi

0 comments on commit 5fbfb78

Please sign in to comment.