Блог Серії
Кар'єра
Вакансії Компанії
Навчання
Співбесіди Тестування Відео
Екосистема
Пакети Ресурси Проєкти
Інше
Події Про нас

Laravel Responsecache

spatie/laravel-responsecache
8.4.1 13 2,802 9M 25 травня 2026 4
На GitHub

Прискорити Laravel-додаток шляхом кешування всього відповіді.

Поділитись

README

Logo for laravel-responsecache

Speed up an app by caching the entire response

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This Laravel package can cache an entire response. By default it will cache all successful GET requests that return text based content (such as HTML and JSON) for a week. This could potentially speed up the response quite considerably.

The first time a request comes in, the package will save the response before sending it to the user. When the same request comes in again, the cached response is returned without going through the entire application.

Here's a quick example:

use Spatie\ResponseCache\Middlewares\CacheResponse;

Route::middleware(CacheResponse::for(minutes(10)))->group(function () {
    Route::get('/posts', [PostController::class, 'index']);
    Route::get('/posts/{post}', [PostController::class, 'show']);
});

For pages where brief staleness is acceptable, you can use flexible caching. After the lifetime expires, the stale response is still served instantly while the cache refreshes in the background. Once the grace period is over, the cache is considered expired and the next request will be fully recalculated:

use Spatie\ResponseCache\Middlewares\FlexibleCacheResponse;

Route::get('/dashboard', [DashboardController::class, 'index'])
    ->middleware(FlexibleCacheResponse::for(lifetime: hours(1), grace: minutes(5)));

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Documentation

All documentation is available on our documentation site.

Testing

You can run the tests with:

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Коментарі

Увійдіть, щоб залишити коментар

Будьте першим, хто залишить коментар!

Схожі пакети

Laravel Ide Helper

barryvdh/laravel-ide-helper

Laravel IDE Helper генерує коректні PHPDocs для всіх Facade класів, щоб покращити автодозаповнення у IDE.

14,925 v3.7.0 13 16

Laravel Dompdf

barryvdh/laravel-dompdf

Обгортка DOMPDF для Laravel, яка дозволяє легко генерувати PDF-документи з HTML-вмісту в ваших Laravel-додатках.

7,265 v3.1.2 13 3

Ziggy

tighten/ziggy

Використовуй назви маршрутів Laravel у JavaScript.

4,307 v2.6.3 9 3

Horizon

laravel/horizon

Панель управління та програмна конфігурація для черг Laravel.

4,150 v5.47.2 13 4

Seotools

artesaos/seotools

Інструменти оптимізації для пошукових систем (SEO) для Laravel та Lumen, що допомагають генерувати метатеги, карти сайту та інші елементи для поліпшення видимості сайту в пошукових системах.

3,355 v1.4.1 13 4

Laravel Analytics

spatie/laravel-analytics

Laravel пакет для отримання даних з Google Analytics.

3,238 5.7.1 13 3