Front page cached after user logs in

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
kdim95
Advanced
Posts: 213
Joined: 26 Aug 2022, 12:17

Front page cached after user logs in

Post by kdim95 » 15 Mar 2023, 14:12

Laravel framework version: 9.52.4
Aimeos Laravel version: ~2022.10
PHP Version: 8.2.3
Environment: Linux

Hello,

I use the following check inside /packages/<my-theme>/views/base.blade.php to determine if the user is logged:

@if (Auth::guest())
user is not logged in
@else
user is logged in
@endif

After logging in and opening the front page, the result of @if (Auth::guest()) is still true (user not logged in).

The cache is cleared when I reload the page in chrome via the shortcut CTRL+SHIFT+R, which ignores cached content.
The cache is also cleared when I load the page via entering the URL to the home page in the address bar.

But clicking the logo leads to the cached homepage, where it appears like the user is still not logged in.
This cache stays for about 30 seconds.

The logo uses {{ airoute('aimeos_home') }}

Do you know how to solve this?

kdim95
Advanced
Posts: 213
Joined: 26 Aug 2022, 12:17

Re: Front page cached after user logs in

Post by kdim95 » 15 Mar 2023, 20:28

I've done a temporary solution by overriding the CatalogController::homeAction() and removing the 30 second cache header, but waiting for a better solution, because it doesn't act like this by default on a clean installation.

User avatar
aimeos
Administrator
Posts: 8026
Joined: 01 Jan 1970, 00:00

Re: Front page cached after user logs in

Post by aimeos » 15 Mar 2023, 21:41

It may makes sense to remove the browser caching in case the user is logged in. If you can create a PR, that checks Auth::user(), we will merge it into the Aimeos Laravel package.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kdim95
Advanced
Posts: 213
Joined: 26 Aug 2022, 12:17

Re: Front page cached after user logs in

Post by kdim95 » 23 Mar 2023, 20:32

My solution was actually not that good, removing the cache only from the home page action doesn't solve it for the other pages, where it still appears like the user is not logged in, when he actually is logged in...

User avatar
aimeos
Administrator
Posts: 8026
Joined: 01 Jan 1970, 00:00

Re: Front page cached after user logs in

Post by aimeos » 27 Mar 2023, 17:01

Guess, browser caching needs to be removed from all catalog controller actions in your case:
https://github.com/aimeos/aimeos-larave ... roller.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply