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

Active 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,
 
#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

Active 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

Top