Bug #94597

Hard reload does not clear cache if adminpanel is activated

Added by Sybille Peters 10 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
AdminPanel
Target version:
-
Start date:
2021-07-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The behaviour of hard refresh (e.g. CTRL-F5 or CTRL-SHIFT-r etc.) is different, depending on if the admin panel is active or not.

Previously, hard refresh could always be used to flush page cache for a page and regenerate it.

Reproduce

With adminpanel

1. Create a page with some content which will change often (e.g. show current time in a plugin) or use this TypoScript:

page >
page = PAGE

page.10 = TEXT
page.10.data = date:U
page.10.strftime = %A %d, %B %Y %H:%M:%S

2. Open this in the browser with adminpanel activated
3. Load page in a different browser (not logged in backend) to make sure cache is filled
4. hard reload on page with logged in backend
5. Load page in different browser (not logged in backend) again to show page as loaded on cache

Repeat this with adminpanel deactivated (is enough to press toggle for switching adminpanel off in FE on bottom right).

Results

The result will be different if adminpanel is deactivated. If adminpanel is deactivated, the cache will not be flushed. In the not logged in browser, the old content will still be displayed.

Settings

Settings in adminpanel using defaults ("No caching" is off. In fact "No caching" seems to have no effect in this case. The page loaded with adminpanel on is always updated. It seems to always generate the page, not use the cache.)

Versions

  • TYPO3 10.4.17
  • current master (11)

PRoblem

This way, the editor can only use hard reload if adminpanel is disabled, with adminpanel he must click on "flush cache of current page".

The hard reload was a convenient method for the rare cases where manual cache flushing is necessary. It was also a convenient method to also flush data from the caching framework (e.g. if used by extensions). Simply using the lighning symbol would not work (because it only flushes and does not regenerate). But with hard-reload, the extension could check if page is reloaded with hard-reload and not get data from caching framework but fetch it fresh.

Solution

The solution might be to flush cache on hard-refresh if adminpanel is active. If this should not be done, it might help to add this information to the documentation.

Documentation

I can no longer find the information about hard reload in the documentation. I am pretty sure, it used to be there. It is still supported, it is in the core.

Code

typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

/**
     * Detecting if shift-reload has been clicked
     * Will not be called if re-generation of page happens by other reasons (for instance that the page is not in cache yet!)
     * Also, a backend user MUST be logged in for the shift-reload to be detected due to DoS-attack-security reasons.
     *
     * @param ServerRequestInterface|null $request
     * @return bool If shift-reload in client browser has been clicked, disable getting cached page (and regenerate it).
     */
    public function headerNoCache(ServerRequestInterface $request = null)
    {
        if ($request instanceof ServerRequestInterface) {
            $serverParams = $request->getServerParams();
        } else {
            $serverParams = $_SERVER;
        }
        $disableAcquireCacheData = false;
        if ($this->isBackendUserLoggedIn()) {
            if (strtolower($serverParams['HTTP_CACHE_CONTROL'] ?? '') === 'no-cache' || strtolower($serverParams['HTTP_PRAGMA'] ?? '') === 'no-cache') {
                $disableAcquireCacheData = true;
            }
        }
        // Call hook for possible by-pass of requiring of page cache (for recaching purpose)
        $_params = ['pObj' => &$this, 'disableAcquireCacheData' => &$disableAcquireCacheData];
        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'] ?? [] as $_funcRef) {
            GeneralUtility::callUserFunction($_funcRef, $_params, $this);
        }
        return $disableAcquireCacheData;
    }

#1

Updated by Susanne Moog 5 months ago

  • Status changed from New to Needs Feedback

Hey,

I cannot reproduce this issue with the current main branch - if it's possible, can you check whether you can reproduce that there, too? I tried shift reload with/without admin panel and using the developer tools in chrome to disable cache and the behaviour is the same independent from the admin panel state.

#2

Updated by Sybille Peters 5 months ago

  • Status changed from Needs Feedback to Closed

I can't reproduce it with latest core version currently, because loading the page with adminpanel enabled leads to an exception on my system: https://forge.typo3.org/issues/96449

On a "clean site" with latest TYPO3 v10 the problem no longer occurs (with adminpanel / without always updates the cache). I will have to check why I had this behaviour on my site and if it is still reprodible there. Closing now.

Also available in: Atom PDF