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.

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

Posted: Sat Aug 21, 2021 8:57 pm
by iamstevenelson
This is your server's issue not Opencart's. Please contact your hosting provider and ask them to change your PHP version from fast CGI to normal CGI version. Disable mod_security if enabled. This should fix this cache issue. I have got the same issue and mine is fixed by this method.

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

Posted: Sat Aug 21, 2021 9:10 pm
by ADD Creative
iamstevenelson wrote:
Sat Aug 21, 2021 8:57 pm
This is your server's issue not Opencart's. Please contact your hosting provider and ask them to change your PHP version from fast CGI to normal CGI version. Disable mod_security if enabled. This should fix this cache issue. I have got the same issue and mine is fixed by this method.
It was probably some other default settings that got changed at the same time you made your changes. What you propose would not directly affect the cache control headers.

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

Posted: Sun May 22, 2022 5:59 am
by Druvan
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!
Thanks for good work. Just want to check. What's the best solution?
Using version 3.0.2.0

Github: https://github.com/opencart/opencart/issues/7008
Two other files are suppose to be changed?

In system framework.php
Line: $response->addHeader('Content-Type: text/html; charset=utf-8');
This line I have three times in framework.php
Cheers!

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

Posted: Sun May 22, 2022 5:59 pm
by ADD Creative
Druvan wrote:
Sun May 22, 2022 5:59 am
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!
Thanks for good work. Just want to check. What's the best solution?
Using version 3.0.2.0

Github: https://github.com/opencart/opencart/issues/7008
Two other files are suppose to be changed?

In system framework.php
Line: $response->addHeader('Content-Type: text/html; charset=utf-8');
This line I have three times in framework.php
Cheers!
Ideally it should be added to the session start up, but adding to the framework is easier and will give the same result. You should only have one line setting the charset in framework.php. You will probably need to compare this against an original file to see why yours is different.

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

Posted: Mon May 23, 2022 5:41 am
by Druvan
ADD Creative wrote:
Sun May 22, 2022 5:59 pm
Druvan wrote:
Sun May 22, 2022 5:59 am
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!
Thanks for good work. Just want to check. What's the best solution?
Using version 3.0.2.0

Github: https://github.com/opencart/opencart/issues/7008
Two other files are suppose to be changed?

In system framework.php
Line: $response->addHeader('Content-Type: text/html; charset=utf-8');
This line I have three times in framework.php
Cheers!
Ideally it should be added to the session start up, but adding to the framework is easier and will give the same result. You should only have one line setting the charset in framework.php. You will probably need to compare this against an original file to see why yours is different.
Hello,
Just download original version again and see that my file is 3x bigger.
I have not made the update myself and maybe why yours solution not working for me.
Attached file. Site is running with no errors but no sure if just to overwrite file.
Maybe some extensions not running?
What you think?

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

Posted: Mon May 23, 2022 6:01 pm
by ADD Creative
Druvan wrote:
Mon May 23, 2022 5:41 am
Hello,
Just download original version again and see that my file is 3x bigger.
I have not made the update myself and maybe why yours solution not working for me.
Attached file. Site is running with no errors but no sure if just to overwrite file.
Maybe some extensions not running?
What you think?
Looks like you have some extension or modification that replaces the framework.php file. On quickly looking at the file you need to add the extra headers after the last two $response->addHeader('Content-Type: text/html; charset=utf-8'); lines and not the first two.

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

Posted: Thu Feb 09, 2023 10:34 pm
by ADD Creative
I've noticed recently that Firefox aggressively caches redirects, which can lead to some other strange issues.

So using header() rather than $response->addHeader() would be better as the later doesn't apply to redirects.

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

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

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

Posted: Thu Jul 06, 2023 5:22 am
by Druvan
You mean it should look like this?
This is for v3.0.2.0

// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
header('Pragma: no-cache', true);
$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);

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

Posted: Thu Jul 06, 2023 5:54 am
by Druvan
ADD Creative wrote:
Thu Feb 09, 2023 10:34 pm
I've noticed recently that Firefox aggressively caches redirects, which can lead to some other strange issues.

So using header() rather than $response->addHeader() would be better as the later doesn't apply to redirects.

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

header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
header('Pragma: no-cache', true);
Hey there,
Just tried the above. I use Mozilla.
It will not autoupdate the admin list after I copy a product.
Still the same, copy with no error but admin list will not update.
Do not know if you same as me.
I write a keyword like: clothes
Copy a product.
I get success message. No update in admin list.
If I now write keyword: cloth
The new will show up

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

Posted: Thu Jul 06, 2023 6:52 am
by ADD Creative
Druvan wrote:
Thu Jul 06, 2023 5:22 am
You mean it should look like this?
This is for v3.0.2.0

// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
header('Pragma: no-cache', true);
$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);
Yes that would be the change.
Druvan wrote:
Thu Jul 06, 2023 5:54 am
Hey there,
Just tried the above. I use Mozilla.
It will not autoupdate the admin list after I copy a product.
Still the same, copy with no error but admin list will not update.
Do not know if you same as me.
I write a keyword like: clothes
Copy a product.
I get success message. No update in admin list.
If I now write keyword: cloth
The new will show up
Once you have made the change you may need to clear you browser cache as it may still have old pages cached.

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

Posted: Sat Jul 08, 2023 5:00 pm
by Druvan
ADD Creative wrote:
Thu Jul 06, 2023 6:52 am
Druvan wrote:
Thu Jul 06, 2023 5:22 am
You mean it should look like this?
This is for v3.0.2.0

// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
header('Pragma: no-cache', true);
$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);
Yes that would be the change.
Druvan wrote:
Thu Jul 06, 2023 5:54 am
Hey there,
Just tried the above. I use Mozilla.
It will not autoupdate the admin list after I copy a product.
Still the same, copy with no error but admin list will not update.
Do not know if you same as me.
I write a keyword like: clothes
Copy a product.
I get success message. No update in admin list.
If I now write keyword: cloth
The new will show up
Once you have made the change you may need to clear you browser cache as it may still have old pages cached.
How do you mean with this.
Can this be a token problem?
Should I clear browser cache when I updated a product?
Are there any other option to turn off cache for admin page?

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

Posted: Sat Jul 08, 2023 7:46 pm
by ADD Creative
Druvan wrote:
Sat Jul 08, 2023 5:00 pm
How do you mean with this.
Can this be a token problem?
Should I clear browser cache when I updated a product?
Are there any other option to turn off cache for admin page?
I mean after you make the changes to system/framework.php to clear your browser cache.

I think you would be better stating your own topic and explain more clearly what the issue is. A step by step guide on how to recreate the error. Also give as much information as you can, as well as your OpenCart version, give your PHP version, theme and any extensions used. Even a link to your site. If you are using any third party cache or proxy, such as CloudFlare. Any errors that show in both the PHP and OpenCart error logs. Any error in your web browser's developer console.