Page 1 of 1

[SOLVED] 3.0.x - minicart not updating, new products and extensions are not showing in the list?

Posted: Fri Aug 17, 2018 3:28 pm
by Dreamvention
Hi Guys

We have been getting soom feedback about users having issues with browser cache. It happens like this:
- you added a product to cart and clicked back and there is zero in your cart. only after refresh, you see the products.
- you installed a new extension, went back to see it and it is not there.
- you added a new product - not showing in list.
- you added a new category - still missing.

this issue is common because of twig and one more - the browser's cache.

Here is the solution
1. go to Dashboard, on the top right you will see a button (blue gear)
2. click the blue gear button and in the popup - turn off the cache and click orange button (refresh)
3. via FTP go to your root folder (public_html or www) and find admin folder
4. in admin folder create a new .htaccess file and edit it

add this code to .htaccess

Code: Select all

<IfModule mod_headers.c>
 <filesMatch "\.(htm|html|css|js|php|tag)$">
   Header set Cache-Control "no-cache, no-store, must-revalidate"
 </filesMatch>
</IfModule>
this should clear the twig cache and also remove the browser cache.

Let me know if this helped anyone?

Re: [SOLVED] 3.0.x - minicart not updating, new products and extensions are not showing in the list?

Posted: Fri May 08, 2020 8:52 pm
by stq137
Dreamvention wrote:
Fri Aug 17, 2018 3:28 pm
Hi Guys

We have been getting soom feedback about users having issues with browser cache. It happens like this:
- you added a product to cart and clicked back and there is zero in your cart. only after refresh, you see the products.
- you installed a new extension, went back to see it and it is not there.
- you added a new product - not showing in list.
- you added a new category - still missing.

this issue is common because of twig and one more - the browser's cache.

Here is the solution
1. go to Dashboard, on the top right you will see a button (blue gear)
2. click the blue gear button and in the popup - turn off the cache and click orange button (refresh)
3. via FTP go to your root folder (public_html or www) and find admin folder
4. in admin folder create a new .htaccess file and edit it

add this code to .htaccess

<IfModule mod_headers.c>
<filesMatch "\.(htm|html|css|js|php|tag)$">
Header set Cache-Control "no-cache, no-store, must-revalidate"
</filesMatch>
</IfModule>

this should clear the twig cache and also remove the browser cache.

Let me know if this helped anyone?
O0 works like magic
thank you

Re: [SOLVED] 3.0.x - minicart not updating, new products and extensions are not showing in the list?

Posted: Fri May 08, 2020 9:11 pm
by stq137
But with your solution, after adding items to cart then clicking store logo, the cart will lose all the items in it !!

how can we fix this ?

Re: [SOLVED] 3.0.x - minicart not updating, new products and extensions are not showing in the list?

Posted: Fri May 08, 2020 9:34 pm
by ADD Creative
This has been reported here. https://github.com/opencart/opencart/issues/7008

The solution posted in this thread is wrong. You should not tell the browser not to cache static files such as .css and .js. This will adversely affect customer experience and increase server load.

The easiest way to fix the lack of cache control headers issue is by making the following change to the framework, since the session is always started. This will ensure the cache control header will only be set when needed.

In system/framework.php find the following line at around line 74.

Code: Select all

$response->addHeader('Content-Type: text/html; charset=utf-8');
After that line add the following.

Code: Select all

$response->addHeader('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
$response->addHeader('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$response->addHeader('Pragma: no-cache');

Re: [SOLVED] 3.0.x - minicart not updating, new products and extensions are not showing in the list?

Posted: Fri May 08, 2020 9:49 pm
by stq137
ADD Creative wrote:
Fri May 08, 2020 9:34 pm
This has been reported here. https://github.com/opencart/opencart/issues/7008

The solution posted in this thread is wrong. You should not tell the browser not to cache static files such as .css and .js. This will adversely affect customer experience and increase server load.

The easiest way to fix the lack of cache control headers issue is by making the following change to the framework, since the session is always started. This will ensure the cache control header will only be set when needed.

In system/framework.php find the following line at around line 74.

Code: Select all

$response->addHeader('Content-Type: text/html; charset=utf-8');
After that line add the following.

Code: Select all

$response->addHeader('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
$response->addHeader('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$response->addHeader('Pragma: no-cache');
So much better, thank you very much for your pass. :D

Re: [SOLVED] 3.0.x - minicart not updating, new products and extensions are not showing in the list?

Posted: Wed Jun 03, 2020 9:02 pm
by peiyichloe20
ADD Creative wrote:
Fri May 08, 2020 9:34 pm
This has been reported here. https://github.com/opencart/opencart/issues/7008

The solution posted in this thread is wrong. You should not tell the browser not to cache static files such as .css and .js. This will adversely affect customer experience and increase server load.

The easiest way to fix the lack of cache control headers issue is by making the following change to the framework, since the session is always started. This will ensure the cache control header will only be set when needed.

In system/framework.php find the following line at around line 74.

Code: Select all

$response->addHeader('Content-Type: text/html; charset=utf-8');
After that line add the following.

Code: Select all

$response->addHeader('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
$response->addHeader('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$response->addHeader('Pragma: no-cache');

hello,
it works! thank you so much

but there is another problem
it works when i adjust the amount by add/minus button
but if i manually enter the designated amount, it doesnt work

do you know how to deal with it then?
thank you so much!

Re: [SOLVED] 3.0.x - minicart not updating, new products and extensions are not showing in the list?

Posted: Thu Jun 04, 2020 5:58 pm
by ADD Creative
The default theme doesn't have plus and minus buttons. This suggests your theme has modified the the add to cart functions. If you can, try the default theme as a test. You may have to contact the theme developer for support.