nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.54k stars 4.08k forks source link

WebDAV is fetched twice on initial page load #45882

Open juliusknorr opened 5 months ago

juliusknorr commented 5 months ago

Steps to reproduce

Current behaviour

The PROPFIND on the root directory is sent twice

Actual behaviour

Only one request should be done

Additional context

Reproducible on 29.0.2 and latest master

Screenshot 2024-06-14 at 14 59 17

@nextcloud/server-frontend

juliusknorr commented 5 months ago

Same is actually the case when going to the recents view and reloading the page

skjnldsv commented 5 months ago

https://github.com/nextcloud/server/blob/1d7893dca899fbcec44c82f049a9c10a085f7153/apps/files/src/views/FilesList.vue#L480-L481

Coming from here @susnux

image

susnux commented 5 months ago

Probably it triggers a settings change directly on init? Or the view is loaded before the settings?

skjnldsv commented 5 months ago

Or the view is loaded before the settings?

probably that

juliusknorr commented 3 months ago

It seems things got worse, so maybe worth to schedule looking into this @sorbaugh

just noticed on my local instance it is doing 4 propfinds against the root on a page load, same on our prod.

skjnldsv commented 3 months ago

On it

susnux commented 3 months ago

I think the reason why it is increasing is that there is no other way for other apps to load the current content.

Meaning if you need the current content of the files app, you have to use view::getContent there is no way to get a cached version of the current content. So if we do not want to introduce new API, we could just extend the current by adjusting View::getContents to have a parameter force = true (most secure backwards compatibility).

This would not need any adjustments of using apps, as the ViewData could stay as it is (so the View constructor call), but we just need to adjust the View class to cache the returned value for a given path and only call the ViewData::getContents when force is set.

skjnldsv commented 3 months ago

Yes and no, there are various issues:

  1. the filter indeed gets their own contents
  2. The Filelist monitors any userConfig store changes, so it gets triggered again on initial populating
  3. The uploader fetch its own content on init too

I'll address 2 and 3 in a minute, still thinking about 1

Basically there was 2 content fetched, and https://github.com/nextcloud/server/pull/45708 added 2 more

skjnldsv commented 3 months ago

3 is fixed by https://github.com/nextcloud-libraries/nextcloud-upload/pull/1313

susnux commented 3 months ago

Nice fixes :)

But I still think we need a way to access the current content without require to refetch, this was possible in legacy file list, but now the only option is view.getContents which is not cached. Not only for us here but also potentially for other apps that hook into files API.

skjnldsv commented 3 months ago

@susnux what about an etag on root, or a similar approach? Then a very tiny request would be easy to know if we're out of date?

skjnldsv commented 3 months ago

Let's re-open for the filter issue https://github.com/nextcloud/server/blob/77cffcb04933795b41b73ccb3850c77c5905dbb7/apps/files_sharing/src/components/FileListFilterAccount.vue#L118

susnux commented 3 months ago

Then a very tiny request would be easy to know if we're out of date?

Yes for some parts this would be quite a nice improvement. But it does not solve this issue, as it would still cause a full request, as we do not know any node.

Also if there are more apps, this issue will grow as each app needs to request the etag.

So we could do both, use the etag and allow getting a cached version.

provokateurin commented 3 months ago

Photos app has the same problem btw, not sure if that will be fixed automatically if it is fixes for Files.

solracsf commented 2 months ago

I don't know if this is related, but many (8 out of 10) PROPFIND requests seen by nginx are doubled, the first being aborted "by the client" (code 499):

PROPFIND /remote.php/dav/files/user/folder/ http_code=499
PROPFIND /remote.php/dav/files/user/folder/ http_code=207

v28.0.9, no sync/webdav clients involved (100% web).