cache-control: no-cache but x-litespeed-cache: hit

#1
Hello,

I'm seeing several WooCommerece websites showing no-cache headers:
Code:
pragma: no-cache
cache-control: no-cache, must-revalidate
even though the request hits the LiteSpeed cache.
Code:
x-litespeed-cache: hit
This is with Browser Cache enabled in the LiteSpeed Cache plugin.

Is there anything else I need to configure in the LiteSpeed Cache plugins for the correct headers to appear?
I have attached a sample output from the header response.

Thanks in advance,
George
 

Attachments

Unique_Eric

Administrator
Staff member
#2
Is there anything you set in htaccess file? Can you provide it as well?
You can also share htaccess through your Environment Report if you feel more comfortable, by Navigate to **LiteSpeed Cache > Report**, press the **Send to LiteSpeed** button, and let us know what it says under "Report Number."
 
#3
i'm getting the similar issue, cache-control: no-cache for everything or i don't see it in the headers

Code:
cache-control: no-cache, must-revalidate
Code:
x-litespeed-cache: hit
 

Unique_Eric

Administrator
Staff member
#4
Hi @adzkii,
Cache-control shows no cache which means no browser cache on this page. Is it possible that you have set any no cache in htaccess file?

You can also share htaccess through your Environment Report if you feel more comfortable, by Navigate to **LiteSpeed Cache > Report**, press the **Send to LiteSpeed** button, and let us know what it says under "Report Number."

I have test it and seems not happens on my default woocommerce testing site.
 
#5
Hi @adzkii,
Cache-control shows no cache which means no browser cache on this page. Is it possible that you have set any no cache in htaccess file?

You can also share htaccess through your Environment Report if you feel more comfortable, by Navigate to **LiteSpeed Cache > Report**, press the **Send to LiteSpeed** button, and let us know what it says under "Report Number."

I have test it and seems not happens on my default woocommerce testing site.
here's the htaccess - https://privatebin.net/?fdaa3f7fd27425d6#cjd9aya5SqIJi+5HDc/zE1/Aft1tCuQkS3LtAu0klRg=
i've PM'd you the report

cheers
 
Last edited by a moderator:

qtwrk

Well-Known Member
#6
Hi,

By default , WP pages are always showing "cache-controlno-cache, must-revalidate, max-age=0"

And browser is not supposed to cache dynamic page.

browser cache means browser will cache the static files like JS/CSS/IMG ...etc

As you can see in my screenshot , the static resources are cached by browser

1.JPG

Best regards,
 

georgetasioulis

Well-Known Member
#7
Hello,

I got a similar reply when I posted this question to the WordPress.org forums https://wordpress.org/support/topic/cache-control-no-cache-but-x-litespeed-cache-hit/ but I'm not sure this is true. For example, here's the default WooCommerce theme, Storefront:

Code:
$ curl -I https://woocommerce.com/storefront/
HTTP/2 200
server: nginx
date: Thu, 06 Dec 2018 17:02:30 GMT
content-type: text/html; charset=UTF-8
x-hacker: If you're reading this, you should visit automattic.com/jobs and apply to join the fun, mention this header.
x-powered-by: WordPress.com VIP <https://vip.wordpress.com>
x-frame-options: SAMEORIGIN
content-security-policy: block-all-mixed-content
x-pingback: https://woocommerce.com/xmlrpc.php
set-cookie: wp_woocommerce_wpcom_signin_nonce=f1a8390fc8dc209cb1c8082bb140e550; expires=Thu, 06-Dec-2018 17:12:30 GMT; Max-Age=600; path=/; secure; HttpOnly
link: <https://woocommerce.com/wp-json/>; rel="https://api.w.org/"
link: <https://woocommerce.com/?p=502191>; rel=shortlink
x-rq: lhr1 87 48 3138
cache-control: max-age=300, must-revalidate
age: 0
x-cache: miss
vary: Accept-Encoding
accept-ranges: bytes
or here's one of their featured WooCommerce brands, Singer:
Code:
$ curl -I https://singerco.com.au
HTTP/2 200
server: nginx
date: Thu, 06 Dec 2018 17:02:01 GMT
content-type: text/html; charset=utf-8
vary: Accept-Encoding
cache-provider: CLOUDWAYS-CACHE-DE
last-modified: Thu, 06 Dec 2018 06:47:40 GMT
vary: Accept-Encoding
cache-control: max-age=2592000
expires: Sat, 05 Jan 2019 16:23:16 GMT
age: 2325
x-cache: HIT
As you can see both have cache-control with a certain max-age. And I'm pretty sure that this is how it was until recently.

Regards,
George
 

qtwrk

Well-Known Member
#8
Hi,

Yes, you got similar answer in WP forum because you were answered by me as well :)

You see that x-cache: miss/hit header? these 2 sites are behind Varnish , that's probably the reason why you see this.

if it is login user , it will show no-cache ,must validate header, and if it is guest user , it actually doesn't show any cache control header.

demo site is set up on cPanel shared hosting server.

What I am trying to say here is that , LSCWP doesn't control over this cache control header nor it can set them, the browser cache feature you see in advance tab is tell browser to cache static resources, as JS and CSS , by rewrite rule in htaccess, and by default WP or WOOC don't send that as well, it is done by other 3rd party plugin.

Code:
ExpiresActive on
ExpiresByType application/pdf A2592000
...
...
and if you open dev tool on https://woocommerce.com/storefront/, it actually doesn't send that header you see in curl.

Best regards,
 

Attachments

#9
I have same problem but my site not wordpress , I dont want to cache my pages ( LiteSpeed Web server dashbord set cache only public )
<IfModule mod_headers.c>
<FilesMatch "\.(flv|js|gif|jpg|jpeg|png|ico|css)$">
Header set Cache-Control "max-age=300, public"
</FilesMatch>
<FilesMatch "\.(html|htm|txt|php)$">
Header set Cache-Control "no-cache, no-store, must-revalidate" // why here not working still caching my page
Header set Pragma "no-cache"
Header set Expires 0
</FilesMatch>
</IfModule>
 

Attachments

serpent_driver

Well-Known Member
#10
@dogan285

These headers are browser cache related and not LiteSpeed cache. If you want to not caching your pages you have to disable cache in plugin settings.

<IfModule mod_headers.c>
<FilesMatch "\.(flv|js|gif|jpg|jpeg|png|ico|css)$">
Header set Cache-Control "max-age=300, public"
</FilesMatch>
<FilesMatch "\.(html|htm|txt|php)$">
Header set Cache-Control "no-cache, no-store, must-revalidate" // why here not working still caching my page
Header set Pragma "no-cache"
Header set Expires 0
</FilesMatch>
</IfModule>
 
#11
I need my pages cached. But many take 50 seconds to load html document.

My thorough screen video: https:// share.descript.com/view/6lXHvKnZz1r

"https:// capture.dropbox.com/m3B85xpQUzVeuK8n"
no-cache, must-revalidate, max-age=0, no-store, private

"https:// share.descript.com/view/yqdQu4bppyd"
Watch my debugging

I shared my info with LS

Also note that I am using Asset Cleanup Pro (but only the offloading of plugins feature, not any optimization).

"https:// townsquare.news/authors/brandon-rogers/"
 

serpent_driver

Well-Known Member
#12
1. You shouldn't use more than 1 plugin for optimizations. Other plugins as LScache plugin are not ready for the page cache and that causes conflicts and malfunctions. LScache plugin has all you need for optimizations.

2. If loading takes so long if page is not cached you should think about upgrading hosting.


************************************************************************************************************************************************************************************************
Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.


************************************************************************************************************************************************************************************************
 
#13
Asset Cleanup Pro is NOT doing any optimizations, it is offloading plugins from regex uris, so those plugins don't load at all on that page.

I have to hace 60 plugins to go our job. They are not needed every type of page. So, we offload them from the types of pages that don't use them.

Buddyboss pages get the BB plugins. The other library types pages get Toolset and Elementor and others.

Cloudways with Apachce, Varnish, Asset Cleanup Pro (to offload plugins) WP Rocket to cache logged in user and Cloudflare APO to cache all assets and logged out users. Load in under 2 seconds, all the time.

LS is supposed to be better. Wp Rocket works perfectly with Asset Cleanup Pro. Why can't LS?
 
#15
I just did a test with Asset Cleanup Pro disabled, and I still saw the exact same 30 second load time on some pages. I suspect LS is trying to prefetch external urls from WP.com. Thoughts?
 

serpent_driver

Well-Known Member
#17
I have to hace 60 plugins to go our job. They are not needed every type of page. So, we offload them from the types of pages that don't use them.
I doubt that this Asset Cleanup plugin does what it claims to do. If it were, your site would load faster. If you think you need 60 plugins to do your job, then you lack the knowledge to upgrade your hosting. You can't install 60 plugins and try to fix the consequences of the 60 plugins with the 61st plugin.

Cloudways with Apachce, Varnish, Asset Cleanup Pro (to offload plugins) WP Rocket to cache logged in user and Cloudflare APO to cache all assets and logged out users. Load in under 2 seconds, all the time.
None of the cache plugins or cache solutions you listed can work better than LScache as long as your site is not cached. If your page is cached, it will load within 2 seconds. That's why there is no problem with LScache. Your problem is the lack of insight that your WordPress installation is overwhelmed with an abnormal number of plugins and data. As long as you don't have this insight, no one can help you.

You also have an SSL problem, so your site cannot load via https://, at least at the moment.

Asset Clean Up Pro Standing in front of the page load and tells what plugins to load on the page. The the caching plugin is supposed to cache the page the loads. Perhaps you can add a hook for your webfrontloader to load through the Asset Cleanup Pro route.
You don't seem to have understood the principle of a page cache yet. If a page is cached, then this cached page is just a static text or HTML file that is stored on your server outside of the www directory, at least that is the case with LScache. LScache does not store the cache within the WordPress directory structure. You can no longer execute PHP code with a static file. That's why the Asset Cleanup Plugin cannot run if a page is cached. I therefore recommend that you deal with the topic of page cache and acquire knowledge of what a page cache is and how this cache works.

I just did a test with Asset Cleanup Pro disabled, and I still saw the exact same 30 second load time on some pages. I suspect LS is trying to prefetch external urls from WP.com. Thoughts?
LScache doesn't load anything from external sources.

Might memberpress be conflicting with LS?
Unfortunately, I don't know memberpress enough, but I know from similar plugins that these plugins are not particularly cache friendly.

If you have further questions, please use support for LScache plugin at WordPress support forum. This forum doesn't support this plugin any longer.

https://www.litespeedtech.com/support/forum/threads/please-use-the-official-wordpress-forum.16028/

************************************************************************************************************************************************************************************************
Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.


************************************************************************************************************************************************************************************************
 
Top