litespeedtech / lscache-laravel

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

Full example of esi in blade #12

Closed mrmmg closed 4 years ago

mrmmg commented 4 years ago

Hi Can you provide a full example of using esi in laravel blade template?

I want to prevent the cache from my topbar and I want to cache it privately. how can I do this?

lucasRolff commented 4 years ago

You can use the example provided in https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:laravel_esi

Instead of <esi:include /> you can use <esi:inline> if you want to handle the code inline instead of generating the code in a separate Route endpoint in Laravel.

The docs for esi:inline can be found here: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:no-plugin-advanced:esi-support?redirect=1#available_html_tags

mrmmg commented 4 years ago

Thank you, It's worked

AdrianEcode commented 1 year ago

Thank you, It's worked

Hi Mohammad!

I know it's been a while since this, but if you still remember it, could you indicate how you finally got it? I tried using this code on the blade but it only worked the first time we access to the page:

<esi:inline name="randnumber" cache-control="no-cache, esi=on">
@php
    $rand_number = rand( 0, 100000000 );
@endphp
<p>Comprobador: {{ $rand_number }}</p>
</esi:inline>
<esi:include src="randnumber" cache-control="no-cache, esi=on" />

Thanks in advance!

mrmmg commented 1 year ago

@AdrianEcode

Hi Unfortunately, I don't remember exactly how I solved this problem. But as far as I can remember, I abandoned the use of such a cache system, because instead of helping me with site performance, it made the discussion of site management and caches more complicated. In any case, I sincerely apologize for not being able to answer your question. With the utmost respect.

AdrianEcode commented 1 year ago

Don't worry @mrmmg , I figured as much after all this time. Thank you very much for reply!