Page 1 of 1
Cart cashe issue
Posted: Fri Jul 26, 2019 9:46 pm
by Zezoiaj
Hello guys , i have an issue of my website .
When Add a new item to cart and go to homepage or any-other page the cart goes to be 0 and when go product page the cart refresh again ..
i tried everything i could
1- turn the host cache off
2- clear cpanel cache
3- clear opencart admin cache
4- restore htaccess to default
5- clear browser cache
nothing helped me out .
i didn't install any new extensions
i use journal 3 theme
opencart 3.0.3.2 latest version
my website link e-electra.com
please help me
Re: Cart cashe issue
Posted: Fri Jul 26, 2019 10:32 pm
by letxobnav
sounds like a browser cache issue.
open chrome developer tools->network->disable cache and try again.
if the issue is gone, you are not sending the correct caching headers to the browser.
Re: Cart cashe issue
Posted: Fri Jul 26, 2019 11:10 pm
by Zezoiaj
Thanks for reply , i did that and tried with 5 deferent browsers but still the same ..
Re: Cart cashe issue
Posted: Sat Jul 27, 2019 12:01 am
by by mona
A site on OC1.5.5.1 had a similar issue.
Turns out we were moved onto a Varnish server - absolutely wonderful for speed, but nothing we tried made it useable for a cart. It is supposed to work - we didn’t find anything for opencart, but there is info about it for wordpress ( for example -
https://docs.easydigitaldownloads.com/a ... th-varnish) - None of these worked, at least not a few years ago. Finally, we move off the varnish server and voila - worked ..
Re: Cart cashe issue
Posted: Sat Jul 27, 2019 8:03 am
by letxobnav
well, in any event, the cache control header is wrong, cloudflare and litespeed may also have a part in it.
cache-control: public, max-age=1
cf-ray: 4fca51a88dc8784e-LAX
content-encoding: br
content-type: text/html; charset=utf-8
date: Fri, 26 Jul 2019 23:57:59 GMT
expect-ct: max-age=604800, report-uri="
https://report-uri.cloudflare.com/cdn-c ... /expect-ct"
expires: Fri, 26 Jul 2019 23:58:00 GMT
server: cloudflare
set-cookie: OCSESSID=4be54b63b49cb7ff1c0feed7ab; path=/
status: 200
vary: Accept-Encoding
x-powered-by: PHP/7.0.33
x-turbo-charged-by: LiteSpeed
Re: Cart cashe issue
Posted: Sat Jul 27, 2019 9:51 am
by Zezoiaj
Thank you guys for your help , the problem has been solved by deleting all cache files from the storage
Re: Cart cashe issue
Posted: Sat Jul 27, 2019 12:25 pm
by by mona
@Zezoiaj your welcome although I had to laugh ..
@letxobnav thank you for that - may I pick your brains on that please. How would you set that up specifically for the cart dropdown OC3.0.3.2 for example?
Re: Cart cashe issue
Posted: Sat Jul 27, 2019 3:32 pm
by letxobnav
well, you basically do not want anything produced by the response class to be cached, not in a proxy and not in the browsers.
So you could send no-cache headers on each individual page and each individual ajax call result like the cart info popup but you might as well set those headers in the response class itself in framework.php
Code: Select all
// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);
would become
Code: Select all
// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
$response->addHeader('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$response->addHeader('Pragma: no-cache');
$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);
that will prevent caching of output produced by response, including ajax call results, so it will not affect other assets like js,css,images which go via expire headers etc.
On a side note, if you install 3rd party cache extensions which circumvent the standard response class or start caching after that class has produced it output or starts sending cache headers that override previously send cache headers, then all bets are off.
Journal themes seem to have a knack for over-caching to compensate for their poor performance due to their bulk designs.
Re: Cart cashe issue
Posted: Sat Jul 27, 2019 6:48 pm
by letxobnav
I see that electera is using cache-control: public, max-age=1 which states that anybody may cache this page even shared caches but only for 1 second.
That works as well.
Re: Cart cashe issue
Posted: Sat Jul 27, 2019 7:52 pm
by by mona
AWESOME
Thank you so very much