Add (cache)
This commit is contained in:
@@ -67,5 +67,8 @@ class Kernel extends HttpKernel
|
|||||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
'horizonBasicAuth' => \App\Http\Middleware\HorizonBasicAuthMiddleware::class,
|
'horizonBasicAuth' => \App\Http\Middleware\HorizonBasicAuthMiddleware::class,
|
||||||
|
|
||||||
|
'cacheResponse' => \Spatie\ResponseCache\Middlewares\CacheResponse::class,
|
||||||
|
'doNotCacheResponse' => \Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"silviolleite/laravelpwa": "^2.0",
|
"silviolleite/laravelpwa": "^2.0",
|
||||||
"spatie/laravel-feed": "^4.3",
|
"spatie/laravel-feed": "^4.3",
|
||||||
"spatie/laravel-googletagmanager": "^2.6",
|
"spatie/laravel-googletagmanager": "^2.6",
|
||||||
|
"spatie/laravel-responsecache": "^7.4",
|
||||||
"spatie/laravel-sitemap": "^6.3",
|
"spatie/laravel-sitemap": "^6.3",
|
||||||
"symfony/dom-crawler": "^6.3",
|
"symfony/dom-crawler": "^6.3",
|
||||||
"tightenco/ziggy": "^1.6",
|
"tightenco/ziggy": "^1.6",
|
||||||
|
|||||||
86
composer.lock
generated
86
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "7419246584579187134315a95c74fa42",
|
"content-hash": "3745e68a419d803a47fdc1dd8f721dca",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "artesaos/seotools",
|
"name": "artesaos/seotools",
|
||||||
@@ -6298,6 +6298,90 @@
|
|||||||
],
|
],
|
||||||
"time": "2023-08-23T09:04:39+00:00"
|
"time": "2023-08-23T09:04:39+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "spatie/laravel-responsecache",
|
||||||
|
"version": "7.4.10",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/spatie/laravel-responsecache.git",
|
||||||
|
"reference": "cf0305f73fcc49dacfadd0f2228887a92fa736ac"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/spatie/laravel-responsecache/zipball/cf0305f73fcc49dacfadd0f2228887a92fa736ac",
|
||||||
|
"reference": "cf0305f73fcc49dacfadd0f2228887a92fa736ac",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/cache": "^8.71|^9.0|^10.0",
|
||||||
|
"illuminate/console": "^8.71|^9.0|^10.0",
|
||||||
|
"illuminate/container": "^8.71|^9.0|^10.0",
|
||||||
|
"illuminate/http": "^8.71|^9.0|^10.0",
|
||||||
|
"illuminate/support": "^8.71|^9.0|^10.0",
|
||||||
|
"nesbot/carbon": "^2.63",
|
||||||
|
"php": "^8.0",
|
||||||
|
"spatie/laravel-package-tools": "^1.9"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"laravel/framework": "^9.0|^10.0",
|
||||||
|
"mockery/mockery": "^1.4",
|
||||||
|
"orchestra/testbench": "^6.23|^7.0|^8.0",
|
||||||
|
"pestphp/pest": "^1.22",
|
||||||
|
"phpunit/phpunit": "^9.4"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Spatie\\ResponseCache\\ResponseCacheServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {
|
||||||
|
"ResponseCache": "Spatie\\ResponseCache\\Facades\\ResponseCache"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Spatie\\ResponseCache\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Freek Van der Herten",
|
||||||
|
"email": "freek@spatie.be",
|
||||||
|
"homepage": "https://spatie.be",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Speed up a Laravel application by caching the entire response",
|
||||||
|
"homepage": "https://github.com/spatie/laravel-responsecache",
|
||||||
|
"keywords": [
|
||||||
|
"cache",
|
||||||
|
"laravel",
|
||||||
|
"laravel-responsecache",
|
||||||
|
"performance",
|
||||||
|
"response",
|
||||||
|
"spatie"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/spatie/laravel-responsecache/tree/7.4.10"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://spatie.be/open-source/support-us",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/spatie",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-10-28T18:47:12+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "spatie/laravel-sitemap",
|
"name": "spatie/laravel-sitemap",
|
||||||
"version": "6.4.0",
|
"version": "6.4.0",
|
||||||
|
|||||||
94
config/responsecache.php
Normal file
94
config/responsecache.php
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
* Determine if the response cache middleware should be enabled.
|
||||||
|
*/
|
||||||
|
'enabled' => env('RESPONSE_CACHE_ENABLED', true),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The given class will determinate if a request should be cached. The
|
||||||
|
* default class will cache all successful GET-requests.
|
||||||
|
*
|
||||||
|
* You can provide your own class given that it implements the
|
||||||
|
* CacheProfile interface.
|
||||||
|
*/
|
||||||
|
'cache_profile' => Spatie\ResponseCache\CacheProfiles\CacheAllSuccessfulGetRequests::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Optionally, you can specify a header that will force a cache bypass.
|
||||||
|
* This can be useful to monitor the performance of your application.
|
||||||
|
*/
|
||||||
|
'cache_bypass_header' => [
|
||||||
|
'name' => env('CACHE_BYPASS_HEADER_NAME', null),
|
||||||
|
'value' => env('CACHE_BYPASS_HEADER_VALUE', null),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the default CacheRequestFilter this setting controls the
|
||||||
|
* default number of seconds responses must be cached.
|
||||||
|
*/
|
||||||
|
'cache_lifetime_in_seconds' => env('RESPONSE_CACHE_LIFETIME', 60 * 60 * 24 * 7),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This setting determines if a http header named with the cache time
|
||||||
|
* should be added to a cached response. This can be handy when
|
||||||
|
* debugging.
|
||||||
|
*/
|
||||||
|
'add_cache_time_header' => env('APP_DEBUG', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This setting determines the name of the http header that contains
|
||||||
|
* the time at which the response was cached
|
||||||
|
*/
|
||||||
|
'cache_time_header_name' => env('RESPONSE_CACHE_HEADER_NAME', 'laravel-responsecache'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This setting determines if a http header named with the cache age
|
||||||
|
* should be added to a cached response. This can be handy when
|
||||||
|
* debugging.
|
||||||
|
* ONLY works when "add_cache_time_header" is also active!
|
||||||
|
*/
|
||||||
|
'add_cache_age_header' => env('RESPONSE_CACHE_AGE_HEADER', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This setting determines the name of the http header that contains
|
||||||
|
* the age of cache
|
||||||
|
*/
|
||||||
|
'cache_age_header_name' => env('RESPONSE_CACHE_AGE_HEADER_NAME', 'laravel-responsecache-age'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Here you may define the cache store that should be used to store
|
||||||
|
* requests. This can be the name of any store that is
|
||||||
|
* configured in app/config/cache.php
|
||||||
|
*/
|
||||||
|
'cache_store' => env('RESPONSE_CACHE_DRIVER', 'file'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Here you may define replacers that dynamically replace content from the response.
|
||||||
|
* Each replacer must implement the Replacer interface.
|
||||||
|
*/
|
||||||
|
'replacers' => [
|
||||||
|
\Spatie\ResponseCache\Replacers\CsrfTokenReplacer::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the cache driver you configured supports tags, you may specify a tag name
|
||||||
|
* here. All responses will be tagged. When clearing the responsecache only
|
||||||
|
* items with that tag will be flushed.
|
||||||
|
*
|
||||||
|
* You may use a string or an array here.
|
||||||
|
*/
|
||||||
|
'cache_tag' => '',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This class is responsible for generating a hash for a request. This hash
|
||||||
|
* is used to look up a cached response.
|
||||||
|
*/
|
||||||
|
'hasher' => \Spatie\ResponseCache\Hasher\DefaultHasher::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This class is responsible for serializing responses.
|
||||||
|
*/
|
||||||
|
'serializer' => \Spatie\ResponseCache\Serializers\DefaultSerializer::class,
|
||||||
|
];
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<aside>
|
<aside>
|
||||||
<form class="d-flex mb-3" action="{{ route('front.search') }}" method="POST">
|
<form class="d-flex mb-3" action="{{ route('front.search') }}" method="POST">
|
||||||
@csrf
|
@csrf
|
||||||
<input name="query" class="form-control me-2" type="search" placeholder="Search for AI news..."
|
<input name="query" class="form-control me-2" type="search" placeholder="Type a keyword..."
|
||||||
aria-label="Search">
|
aria-label="Search">
|
||||||
<button class="btn btn-outline-primary" type="submit">
|
<button class="btn btn-outline-dark border-2" type="submit">
|
||||||
<i class="bi bi-search"></i>
|
<i class="bi bi-search"></i> Search
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
@@ -15,15 +15,16 @@
|
|||||||
|
|
||||||
Route::feeds('feeds');
|
Route::feeds('feeds');
|
||||||
|
|
||||||
Route::get('/', [App\Http\Controllers\Front\FrontHomeController::class, 'home'])->name('front.home');
|
Route::get('/', [App\Http\Controllers\Front\FrontHomeController::class, 'home'])->name('front.home')->middleware('cacheResponse:3600');
|
||||||
|
|
||||||
Route::get('/terms', [App\Http\Controllers\Front\FrontHomeController::class, 'terms'])->name('front.terms');
|
|
||||||
|
|
||||||
Route::get('/privacy', [App\Http\Controllers\Front\FrontHomeController::class, 'privacy'])->name('front.privacy');
|
Route::get('/terms', [App\Http\Controllers\Front\FrontHomeController::class, 'terms'])->name('front.terms')->middleware('cacheResponse:2630000');
|
||||||
|
|
||||||
Route::get('/disclaimer', [App\Http\Controllers\Front\FrontHomeController::class, 'disclaimer'])->name('front.disclaimer');
|
Route::get('/privacy', [App\Http\Controllers\Front\FrontHomeController::class, 'privacy'])->name('front.privacy')->middleware('cacheResponse:2630000');
|
||||||
|
|
||||||
Route::get('/bites', [App\Http\Controllers\Front\FrontListController::class, 'index'])->name('front.all');
|
Route::get('/disclaimer', [App\Http\Controllers\Front\FrontHomeController::class, 'disclaimer'])->name('front.disclaimer')->middleware('cacheResponse:2630000');
|
||||||
|
|
||||||
|
Route::get('/bites', [App\Http\Controllers\Front\FrontListController::class, 'index'])->name('front.all')->middleware('cacheResponse:3600');
|
||||||
|
|
||||||
Route::post('/search', [App\Http\Controllers\Front\FrontListController::class, 'search'])->name('front.search');
|
Route::post('/search', [App\Http\Controllers\Front\FrontListController::class, 'search'])->name('front.search');
|
||||||
|
|
||||||
@@ -33,4 +34,4 @@
|
|||||||
|
|
||||||
Route::get('/{category_slug}', [App\Http\Controllers\Front\FrontListController::class, 'category'])
|
Route::get('/{category_slug}', [App\Http\Controllers\Front\FrontListController::class, 'category'])
|
||||||
->where('category_slug', '^(updates|opinions|features|new-launches|how-tos|reviews)$')
|
->where('category_slug', '^(updates|opinions|features|new-launches|how-tos|reviews)$')
|
||||||
->name('front.category');
|
->name('front.category')->middleware('cacheResponse:3600');
|
||||||
|
|||||||
Reference in New Issue
Block a user