Hello!

My users can't reach fresh content until I don't clear full cache manually.

Steps:
1. Upload a file by admin
2. Open private browser, check your dir listings (filebrowser_node_view called) You see the new file.
3. Upload another file by admin
4. Refresh your private browser (filebrowser_node_view is not called) You don't see the newest file. But the admin sees it.

There is no fresh content!
Do you have any idea?

Comments

kecsot created an issue. See original summary.

kecsot’s picture

Priority: Major » Normal
clivesj’s picture

In D8 the hook node_view changed to utilize the new caching.
If there is no change in the context D8 will not call node_view.
For Filebrowser that was a problem obviously since we uploading outside Drupal context.
We solved it by disabling all caching for the node type dir_listing.
So, every time the browser calls a directory listing node view will be called, Filebrowser makes a trip to the storage and shows the files.
It is a bit expensive but that's the only way I could find so far to circumvent the cache. That's the intended behavior. If it doesn't we have a bug.

We haven't had any complaint since we changed that a long time ago.
I have followed your steps, but can not reproduce.
I printed out a hash for each node_view and confirmed that node_view is called all the time.
But there might be some situation that cache still serves the page.
Do you have the listing in a block? Does it affect non-logged-in users? You have other caching items that may affect?
We might have to drill it down to a specific case.

btw:
If at step 3 you uploaded the file trough the interface you *don't* have to refresh to see the new file as FB refreshes itself.
But if you uploaded outside of FB then indeed you have to refresh.

kecsot’s picture

I installed a new drupal with composer and I enabled your module.
Then I added new content (directory_listing). url was node/1
Then I repeat my steps from 1-4 and the issue has still happened. (When the private browser is an anonymous user!)

https://www.drupal.org/docs/8/api/cache-api/cache-max-age#s-limitations-...

Unfortunately, max-age does not work for anonymous users and the Drupal core Page Cache module.

https://drupal.stackexchange.com/questions/185215/how-do-i-disable-twig-...

If you want to disable the cache for anonymous users without a session:

// Deny any page caching on the current request.    
\Drupal::service('page_cache_kill_switch')->trigger();

So, I added this code after the max-age and it works for anonymous users. (in method filebrowser_node_view )

Please try to reproduce it in a clear new drupal. (8.7.10)

kecsot’s picture

Version: 8.x-2.x-dev » 8.x-2.0

  • clivesj committed 3babf25 on 8.x-2.x authored by kecsot
    Issue #3096598 by kecsot: filebrowser_node_view not called second time
    
clivesj’s picture

Status: Active » Fixed

Maybe it's because of my setup, but I can not reproduce.
But it seems obvious that we need the kill switch for anonymous users. I have added it.
Thank you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.