litespeedtech / lscache-laravel

LSCache for Laravel framework
GNU General Public License v3.0
51 stars 14 forks source link

Lscache tabs max-age not working (Cache-Control) #17

Closed eliassdogos closed 3 years ago

eliassdogos commented 3 years ago

I installed lscache with these steps https://docs.litespeedtech.com/lscache/lsclaravel/installation/. At .env i have LSCACHE_ESI_ENABLED=true LSCACHE_DEFAULT_TTL=108000 At laravel/public/.htacess
< IfModule LiteSpeed > CacheLookup on </ IfModule > In web.php for homepage i set Route::get('/', 'Controller@index') ->middleware(['lscache:max-age=108000;public;', 'lstags:home']);

but in f12 i am ok with X-LiteSpeed-Cache: hit X-LS-Pagespeed: 2.1-1.11.33.4 https://i.imgur.com/e9XiXQd.png but how to set "Cache-Control: public,max-age=108000" instead "Cache-Control: no-cache, private,public" and see tag "home"?

qtwrk commented 3 years ago

you are mistaking the LiteSpeed Cache and Browser Cache.

for Cache-Control: public,max-age=108000

you need to use .htaccess with Header directive , e.g.

Header set Cache-Control "public,max-age=108000"

but be careful , this will force browser to cache dynamic pages which serves user the out-dated or stalled content , you may not want to do this over a dynamic page.

eliassdogos commented 3 years ago

@qtwrk thank you about browser cache, Also what about LScache => Route::get('/', 'Controller@index') ->middleware(['lscache:max-age=108000;public;', 'lstags:home']); Why i dont see lstag and max age in headers https://i.imgur.com/e9XiXQd.png ?

qtwrk commented 3 years ago

yes, it's hidden header , you can only see it in server debug log.

only visible to end-user is x-litespeed-cache header , the tag and TTL header won't show

eliassdogos commented 3 years ago

Thank you.

eliassdogos commented 3 years ago

@qtwrk since the tag and TTL header won't show why i can see tag "Admin" in another route. https://i.imgur.com/D1dKkUV.png In web.php routes i have Route::group(['prefix' => 'admin', 'middleware' => ['lscache:no-cache;', 'lstags:admin']], function () {

... .. .. }

lucasRolff commented 3 years ago

Internal/Hidden headers are always exposed with no-cache and whenever the request is a miss(didn't hit cache). When you get a hit those internal/hidden headers are not present.

eliassdogos commented 3 years ago

Thank you