-
-
Notifications
You must be signed in to change notification settings - Fork 213
pages always come from cache, regardless of backend login or frontend preview #8249
Comments
|
Excellent summary of a well-known problem: #3184 |
|
I tried to fix it myself, by setting $_SESSION['DISABLE_CACHE'] = true;right when the user logs into the backend. However, it did not work due to the Thus, the easiest fix is simply adding \Input::cookie('BE_USER_AUTH')to these conditions. This works as expected: whenever you are logged into the backend, you never get a page from the page cache. As soon as you are logged out of the backend, pages come from the cache again (when present, otherwise they are generated for the cache first). With this you can also remove |
That issues does not seem to be related. Georg was originally talking about discrepancies that can happen, if pages comes from the cache and others do not. Like main menus not displaying the complete site structure, if a page is loaded from the cache (after a new pages had been added to the site structure). This particualy problem can be solved easily with insert tags (or in other more complicated ways). This issue is about something else - this issue is about a page always coming from the page cache, even if you are logged into the backend and even if you are using the frontend preview. The intended behavior is that pages are not served from the page cache, if you are logged into the backend, which is what the |
|
Is there any reason not to add \Input::cookie('BE_USER_AUTH')to FrontendIndex.php#L313 and remove the |
|
As discussed in Mumble on June 16th, we want to add |
|
Added in c1d401a. |
Problem description
Even if you log into the backend and/or use the frontend preview, pages are always loaded from the cache, when present, under certain circumstances. (More apt description: pages are not loaded from the cache under certain circumstances, when logged into the backend - see below.)
Reproduction
var_dump($_SESSION['DISABLE_CACHE']);here (orecho 'foo';after the condition, or whatever you like)The page "Foo" will always come from the cache, no matter how many times you reload.
If you want to check the same thing with the frontend preview, you need to do the following:
var_dump($_SESSION['DISABLE_CACHE']);here (orecho 'foo';after the condition, or whatever you like)Note: You need at least Contao
3.5.0(I think) for the second reproduction steps to work, because in older versions the index page might not get properly cached.Cause
I have outlined the cause already here in german: #8233 (comment)
Usually, pages won't be loaded from the cache under a number of conditions: FrontendIndex.php#L295
One of these conditions is the session variable
This variable will only be set to true in the function Frontend::getLoginStatus
and this function is only called by FrontendIndex::__construct, but only AFTER (!)
Thus, if you never, ever visit a page in the frontend which is not already present in the page cache, the variable
$_SESSION['DISABLE_CACHE']will never be set to true and thus you will always receive the page from the cache, even when logged into the backend.The text was updated successfully, but these errors were encountered: