litespeedtech / lscache-laravel

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

Feature: Possibility to enable/disable caching for logged in users #7

Closed niladam closed 4 years ago

niladam commented 4 years ago

It would be great if i could be able to disable cache on an per-auth setting.

I'm thinking this would involve some sort of config key (maybe guests_only) and probably a check if the user is logged in or not.

Also, maybe it could automatically build a private cache (per user setting?) automatically if the user is logged in..

lucasRolff commented 4 years ago

Hi @niladam ,

I'm thinking this would involve some sort of config key (maybe guests_only) and probably a check if the user is logged in or not.

I've pushed this to master, so you can try out dev-master via composer, you'll have to publish the new config:

php artisan vendor:publish --provider="Litespeed\LSCache\LSCacheServiceProvider"

Then you can either use LSCACHE_GUEST_ONLY in your .env file and set it to true or set it to true directly in config/lscache.php.

Let me know if it works for you, then I'll get it tagged and release as an official version.

Also, maybe it could automatically build a private cache (per user setting?) automatically if the user is logged in..

I like the idea, but it's a bit harder, since we have to make purging work as expected as well (purging both public and private cache when using URIs, tags etc), but I'll see what I can do!

niladam commented 4 years ago

Hey @lucasRolff - thank you for your really quick improvement and addition.

I've made some minor changes to your previous commit and made a pull request about it. I've documented the guest_only functionality as well, and also made sure to reference this issue and your initial commit in it.

When the PR (if) is accepted this should automatically close this issue (as far as i'm aware)

In case you're seeing this first (as opposed to seing the PR) the PR is #8 :)

Thanks, Madalin.

niladam commented 4 years ago

Hey @lucasRolff - thank you for the merge accept. Can you also make sure to release the latest version and maybe close this ?:)

lucasRolff commented 4 years ago

v1.2.0 has been pushed - thanks for your contribution @niladam !