Cache issue

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!
Alexey
Posts: 2
Joined: 19 Jul 2023, 10:35

Cache issue

Post by Alexey » 19 Jul 2023, 10:39

Hi, I'm using a version of it:
Laravel Framework 8.83.27
"aimeos/aimeos-laravel": "~2020.10"
PHP 7.4.30

I have added a root for category output:
Route::get('category/{category_name?}', '\Aimeos\Shop\Controller\CatalogController@listAction')->name('aimeos_shop_list_category');

I'm using the default controller
vendor/aimeos/aimeos/aimeos-laravel/src/Aimeos/Shop/Controller/CatalogController.php

The problem is the following, I see that the cache is not working correctly, it always caches the first page to which the transition occurs.

i.e. if I go to http://aimeos-shop.local.com/category/test_1.

it will cache it, and if I go to another category - http://aimeos-shop.local.com/category/test_2.
The cache will pull up the HTML for the test_1 category.

The only solution is to go to /ext/ai-client-html/client/html/src/Client/Html/Base.php and in the getParamHash method.
add request()->getRequestUri() to $pstr.

The question is, how should this work, why is the cache only caching the first page?

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

Re: Cache issue

Post by aimeos » 20 Jul 2023, 08:19

The parameter name "category_name" isn't used to calculate the hash for caching. If you name the parameter "f_..." (e.g. "f_catname"), then caching should work as expected. Here's the reference in the code:
https://github.com/aimeos/ai-client-htm ... rd.php#L99
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Alexey
Posts: 2
Joined: 19 Jul 2023, 10:35

Re: Cache issue

Post by Alexey » 24 Jul 2023, 08:47

It seems that with this approach, all products from all categories are displayed in one category, and there is also caching on the 1st access.

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

Re: Cache issue

Post by aimeos » 25 Jul 2023, 09:20

If you didn't pass the new parameter as search filter to the Aimeos product controller, you will get back all products from all categories for sure.

With the new parameter, caching is still applied but now, the value of the parameter is taken into account when calculating the cache hash.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply