sentinel-dvlpr/laravel-last-modified 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sentinel-dvlpr/laravel-last-modified

最新稳定版本:v1.1.0

Composer 安装命令:

composer require sentinel-dvlpr/laravel-last-modified

包简介

Setting the Last-Modified header and 304 Not Modified response code if the page hasn't changed since the last visit

README 文档

README

Last-Modified / 304 Not Modified Handler for Laravel

Easily setting the Last-Modified header and 304 Not Modified response code.

Packagist Version GitHub Tests Status GitHub Code Style Status PHP Version Support License

Requirements

  • PHP 7.4 - 8.3
  • Laravel 8.x - 11.x

Installation

You can install the package via composer:

composer require abordage/laravel-last-modified

Optionally, you can publish the config file with:

php artisan vendor:publish --tag="last-modified-config"

Usage

The setup is very simple and consists of two steps:

Registering middleware

// in app/Http/Kernel.php

protected $middleware = [
    'web' => [
        // other middleware
        
        \Abordage\LastModified\Middleware\LastModifiedHandling::class,
    ],
];

Set Last Update Date in your Controller

<?php
 
namespace App\Http\Controllers;
 
use App\Http\Controllers\Controller;
use LastModified;
 
class PostController extends Controller
{
    public function show($id)
    {
        $post = \App\Models\Post::findOrFail($id);

        LastModified::set($post->updated_at);
        
        return view('posts.show', ['post' => $post]);
    }
}

It's all. Now you can check the headers.

How to check headers

You can check headers in the browser console under the Network tab (make sure Disable Cache is off)

or

using https://last-modified.com/en

Check Last-Modified

Testing

composer test:all

or

composer test:phpunit
composer test:phpstan
composer test:phpcsf

or see https://github.com/abordage/laravel-last-modified/actions/workflows/tests.yml

Feedback

If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-17