Downloads
Stars
Version
Additions to Spatie's speed up a Laravel app by caching the entire response package so that Mobile and Desktop visitors view different websites.
You can install the package via composer:
composer require deniztezcan/laravel-responsecache-additions
The package will automatically register itself.
You can publish the config file with:
php artisan vendor:publish --provider="Spatie\ResponseCache\ResponseCacheServiceProvider"
Replace the following line
'hasher' => \Spatie\ResponseCache\Hasher\DefaultHasher::class,
with
'hasher' => \DenizTezcan\ResponseCache\Hasher\MobileHasher::class,
This will make sure Mobile and Desktop visitors view different websites. If you want to make sure a specific area of the website get's replaced by a live version please change:
'replacers' => [
\Spatie\ResponseCache\Replacers\CsrfTokenReplacer::class,
],
with your own replacer, for instance located in App\Replacers\FooReplacer
'replacers' => [
\Spatie\ResponseCache\Replacers\CsrfTokenReplacer::class,
\App\Replacers\FooReplacer::class,
],
The FooReplacer
can consists of the following
<?php
namespace App\Replacers;
use DenizTezcan\ResponseCache\Replacers\BladeFilesReplacer;
class FooReplacer extends BladeFilesReplacer
{
protected string | array $htmlTag = 'fake-html-tag'; // html tag without the <> in string or array format
protected string | array $realTimeView = 'partials.fake-blade-loc'; // blade path string or array format
}
this will replace the content of the partials.fake-blade-loc
.