deniztezcan/laravel-responsecache-additions

Speed up a Laravel application by caching the entire response additions

Downloads

58

Stars

0

Version

v1.0.3

Laravel Response Cache additions

Latest Version on Packagist MIT Licensed Total Downloads

Additions to Spatie's speed up a Laravel app by caching the entire response package so that Mobile and Desktop visitors view different websites.

Installation

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 with the on load view renderings of the file partials.fake-blade-loc.

deniztezcan

Author

deniztezcan