Giter Club home page Giter Club logo

laravel-httpcache's Introduction

HttpCache for Laravel

Tests Packagist License Latest Stable Version Total Downloads Fruitcake

Laravel can use HttpKernelInterface Middlewares, so also HttpCache. This package provides a simple ServiceProvider to get you started with HttpCache.

First, require this package with composer

composer require barryvdh/laravel-httpcache

After updating, add the ServiceProvider to the array of providers in app/config/app.php

'Barryvdh\HttpCache\ServiceProvider',

You can now add the Middleware to your Kernel:

'Barryvdh\HttpCache\Middleware\CacheRequests',

Caching is now enabled, for public responses. Just set the Ttl or MaxSharedAge

Route::get('my-page', function(){
   return Response::make('Hello!')->setTtl(60); // Cache 1 minute
});

You can use the provided SetTtl middleware in your Kernel to simplify this:

protected $routeMiddleware = [
    // ...
    'ttl' => \Barryvdh\HttpCache\Middleware\SetTtl::class,
];

Route::get('my-page', function(){
   return 'Hello' 
})->middleware('ttl:60'); // Cache 1 minute

Publish the config to change some options (cache dir, default ttl, etc) or enable ESI.

$ php artisan vendor:publish --provider="Barryvdh\HttpCache\ServiceProvider"

Direct approach, without ServiceProvider

Note: This is still in beta, test with caution. It should be faster, but less flexible because it starts earlier.

You can also wrap the Kernel in the HttpCache, in your public/index.php. Replace the 'Run The Application' part like this:

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$kernel = \Barryvdh\HttpCache\CacheKernel::wrap($kernel);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

ESI

Enable ESI in your config file and add the Esi Middleware to your Kernel:

'Barryvdh\HttpCache\Middleware\ParseEsi',

You can now define ESI includes in your layouts.

<esi:include src="<?= url('partial/page') ?>"/>

This will render partial/page, with it's own TTL. The rest of the page will remain cached (using it's own TTL)

Purging/flushing the cache

You can purge a single url or just delete the entire cache directory:

App::make('http_cache.store')->purge($url);
\File::cleanDirectory(app('http_cache.cache_dir'));

Or use the Artisan httpcache:clear command

$ php artisan httpcache:clear

More information

For more information, read the Docs on Symfony HttpCache

laravel-httpcache's People

Contributors

aidanwatt avatar allowing avatar anchepiece avatar barryvdh avatar fideloper avatar gonzahce avatar hannesvdvreken avatar hootlex avatar laravel-shift avatar okaufmann avatar omranic avatar roennow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-httpcache's Issues

Session not store on request

Hello @barryvdh ,

I implemented the httpcache with your settings and testing it on my local environment with docker worked fine. When uploading the change ( with the docker also ) it broke and got 'Session not store on request' for some calls that where private.

Your middleware was added:

    protected $middleware = [
        \Barryvdh\HttpCache\Middleware\CacheRequests::class,
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
    ];

So all request where checked if they had a httpcache page. In the documentation doesn't says anything about where to put that. And I'm wondering if this middleware disables somehow the session.

Can you guide me a little on that issue?

thanks

Laravel 6.0 Support

Tell me how soon to wait for support Laravel 6.0?
A new version of the framework has been officially released.

Laravel 5.1 comaptibility

Hi, I was trying to upgrade to L5.1 by using composer. I got this problem: requires Illuminate/support 5.0.x.

Any chances you could upgrade your composer.json list?

Unresolvable dependency issue

Very interested in trying out this service provider but I'm getting this error when all loaded up:

Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\ServiceProvider

Any ideas? Thanks,

-Garrett

Route middleware memory exhausted

I'm using dingo/api and I want to exclude the caching middleware for API routes so instead of registering the middlware in the kernel $middleWare property I wanted to use the routemiddleware.
However when registeren it like so:

        'httpcache.cache' => \Barryvdh\HttpCache\Middleware\CacheRequests::class,
        'httpcache.esi' => \Barryvdh\HttpCache\Middleware\ParseEsi::class,

and then loading it like so:

Route::group(['middleware' => ['httpcache.cache','httpcache.esi'] ], function(){

results in a memory exhausted fatal error. When I load just of the two it works fine.
Any clue on what this might be?

edit: changed endless loop to memory exhausted fatal error

Session Issue

Hello @barryvdh
I implemented the HTTP cache in Laravel and it is working fine. But I am getting the session issue so I took the reference of this PR #31

Before implemented the code:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Barryvdh\HttpCache\Middleware\CacheRequests::class,
\Barryvdh\HttpCache\Middleware\ParseEsi::class,
];
Took reference after implemented the below code:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];
And add some code in route.php like this:
Route::get('partial/cart-qty','Cart\Controllers\CartController@getItemCount')->middleware(['\Barryvdh\HttpCache\Middleware\CacheRequests::class','\Barryvdh\HttpCache\Middleware\ParseEsi::class']);
I have using this route for the ESI:
<esi:include src=""/>
So can you help me for the little issue ?
Thanks

View responses break HttpCache in Symfony

When returning a view from a controller, everything breaks cause it's not an instance of Response..

I tried simply overriding the HttpCache but it's entirely private (annoying) so had to copy the file.

Any thoughts on how to remedy this in a more elegant manner?

I also tried checking the response type prior and converting to response object but it's no use if you have to evaluate the response to test it - cache is missed at that point.

Here is all I did to catch it: laravel-streams/streams-core@4550c20#diff-8811282b9f527c7bce6daf4944b4ebe5R489

Disabling the cache does not work

In file config/httpcache.php there is an option enabled, the value of which is set from the env file:

'enabled'   => env('HTTPCACHE_ENABLE', true),

I tried setting the value of this variable to different values:

HTTPCACHE_ENABLE=
HTTPCACHE_ENABLE=0
HTTPCACHE_ENABLE=false
HTTPCACHE_ENABLE=null

But none of the options work. The application still caches pages.

Also, in the package code I did not find where the caching disable key is used.

The impossibility of disabling the package is hampered by the fact that during the project layout, each time it is necessary to run the console command to clear the cache and only then refresh the page in the browser.
Therefore, the use of "live reload" becomes meaningless.

a simple question.

hi there, many thanx for this package, i was going through learning more about varnish and this seems to be to do all i want without getting into to much server jargon,
however there is something i cant quite understand and i googled for quite sometime but without any actual result, so my question is

as stated on blade docs that views gets cached and then changed when the included partials inside it is updated which is good,
but now i read about ESI and i cant see what exactly is the benefit of it if blade + some ajax does exactly the same.

Cannot logout

I cannot use auth()->logout() after at the httpcache middleware, It still logged in, so I have to modify the kernel like this.

    public function handle($request)
    {
        $ignores = [
            "login",
            "logout",
            "auth(.+)",
            "admin(.+)",
            "register",
        ];
        $pattern = implode('|', $ignores);

        // Ignore middleware from some routes.
        if (! preg_match('~'.$pattern.'~', $request->path())) {
            $this->prependMiddleware('Barryvdh\HttpCache\Middleware\ParseEsi');
            $this->prependMiddleware('Barryvdh\HttpCache\Middleware\CacheRequests');
        }

        return parent::handle($request);
    }

This package led to can't cache images output by spatie/laravel-glide

These days I am trying image processing,and tried spatie/laravel-glide base on http://glide.thephpleague.com/, and at the same time I used your httpcache pakage.
what make me crazy is no matter how to try images can't be cached by browers.
spended lots of time ,finally i found that every time I send a request to server,the below function in symfony Response:
public function isNotModified(Request $request)
{
if (!$request->isMethodSafe()) {
return false;
}

    $notModified = false;
    $lastModified = $this->headers->get('Last-Modified');
    $modifiedSince = $request->headers->get('If-Modified-Since');

    if ($etags = $request->getETags()) {
        $notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags);
    }

    if ($modifiedSince && $lastModified) {
        $notModified = strtotime($modifiedSince) >= strtotime($lastModified) && (!$etags || $notModified);
    }

    if ($notModified) {
        $this->setNotModified();
    }

    return $notModified;
}

was called twice.

[2015-11-21 07:54:05] local.INFO: Cache-Control: max-age=31536000, public
Content-Length: 12120
Content-Type: image/jpeg
Date: Sat, 21 Nov 2015 07:54:05 GMT
Expires: Mon, 21 Nov 2016 07:54:05 GMT
Last-Modified: Sat, 21 Nov 2015 05:26:38 GMT

[2015-11-21 07:54:05] local.INFO: Cache-Control: private
Content-Type: text/html; charset=UTF-8
Date: Sat, 21 Nov 2015 07:54:05 GMT
X-Symfony-Cache: GET /img/greatwall?filt=greyscale&q=60&s=f731d23929793b5021f7a00c0ab6c855&w=300: miss

Then I removed http-cache related middleware,It worked,got 304 and isNotModified only called once,
[2015-11-21 07:56:47] local.INFO: Cache-Control: max-age=31536000, public
Content-Length: 12120
Content-Type: image/jpeg
Date: Sat, 21 Nov 2015 07:56:47 GMT
Expires: Mon, 21 Nov 2016 07:56:47 GMT
Last-Modified: Sat, 21 Nov 2015 05:26:38 GMT

httpcache cased that can't get
$lastModified = $this->headers->get('Last-Modified');
$modifiedSince = $request->headers->get('If-Modified-Since');
at same time. So every time isNotModified() executed,return false.

I haven't research why httpcache package cased the problem,you could give me some explanation ,thank you very much .
I use this link to test ,
http://www.bigfeettrip.com/img/greatwall?w=300&q=60&filt=greyscale&s=f731d23929793b5021f7a00c0ab6c855

Class http_cache.store does not exist

I'm getting the following error when trying to purge a URI from cache in Laravel 5.4:

$url = url('properties', [$property_id]);
App::make('http_cache.store')->purge($url);

ReflectionException in Container.php line 681:
Class http_cache.store does not exist

Is this something on my end that I'm overlooking?

TTL for Route group?

Sorry if this is a basic question, is there an example of setting the TTL for a route group?

Question

Does this package Does the same thing as optimizing your nginx conf to leverage browser caching?
If yes what is the benefit of this package compare to using it directly in your server nginx conf?

Hope my mind can be clear thanks

Error HttpFoundation\Request::isMethodSafe() is deprecated

Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0.

Disable checking only for cacheable methods by calling the method with false as first argument or use the Request::isMethodCacheable() instead.

Update to work with laravel 5.6?

Problem 1
- Installation request for barryvdh/laravel-httpcache ^0.3.0 -> satisfiable by barryvdh/laravel-httpcache[v0.3.0].
- Conclusion: remove laravel/framework v5.6.3
- Conclusion: don't install laravel/framework v5.6.3
- barryvdh/laravel-httpcache v0.3.0 requires illuminate/support 5.1.x|5.2.x|5.3.x|5.4.x|5.5.x -> satisfiable by illuminate/support[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
- don't install illuminate/support v5.1.1|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.13|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.16|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.2|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.20|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.22|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.25|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.28|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.30|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.31|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.41|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.6|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.1.8|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.0|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.19|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.21|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.24|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.25|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.26|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.27|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.28|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.31|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.32|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.37|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.43|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.45|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.6|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.2.7|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.3.0|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.3.16|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.3.23|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.3.4|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.4.0|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.4.13|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.4.17|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.4.19|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.4.27|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.4.36|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.4.9|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.0|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.16|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.17|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.2|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.28|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.33|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.34|don't install laravel/framework v5.6.3
- Installation request for laravel/framework (locked at v5.6.3, required as ^5.6) -> satisfiable by laravel/framework[v5.6.3].

Not working with json format

Hi, 1st of all thank you for making the Symphony's httpcache available for Laravel.
Anyhow the Response::json()->setTtl(); doesn't return the cached version, only Response::view does ?!!

ESI: multiple questions

I have a website that consists of mainly user generated content. To speed things a little bit up I started to play around with this package.

Enabling cache brings the response time from ~600ms down to ~80ms on my local Vagrant box, which is great! However, there are small parts in the navigation that should never be cached, like the login button / profile link (in case the user is logged in) and other navigation elements.

So here are my beginner questions:

  1. I made a partial view and included it with ESI and set the cache time to 0. The page content is cached except for the login stuff. This seemed to work. But is this the right way to do that?

  2. Is invalidating the cache possible with this package? I want the cache to be refreshed when a new "item" is submitted by a user, but otherwise cache that page with all items on it as long as possible.

  3. Is it an issue when the above mentioned ESI fragments are publicly accessible (in a browser for example)? There is a trusted proxies setting in Symfony. Would that render those URLs protected for direct Browser access?

Thanks a lot for your help in advance!

ESI: Illuminate request expected

I've been trying to get the ESI rendering to work in a regular Laravel 5/5.1 install.
There seem to be a few issues that I'm running into that you may have resolved already.

The (sub)request generated by the ESI service is a Symfony request instead of a Illuminate request. Several Laravel services expect the Illuminate request and, without setting the factory callable on the Symfony request class to return a Illumate request, the application will crash straight away.

Replacing the request will allow the request to go through, but it will never be handled by the Illuminate kernel (it's handled by your ClosureHttpKernel instead). All default middleware will therefore never run, and again crash the application.

Did you manage to get this to work?

Edit: I didn't add the middlewares at the top in my kernel, doing so will make the other middlewares run on the subrequest.

Missing middleware ttl

@barryvdh When using composer install the package

"barryvdh/laravel-httpcache": "0.2.x@dev"

The package is missing the

'ttl' => \Barryvdh\HttpCache\Middleware\SetTtl::class,

composer install barryvdh/laravel-httpcache the class is in the package

Cache Control Header

I have created an API with Laravel 5 and I want to setup HTTP Caching.

I have the following method:

public function respond($data)
{
    $response = response()->json($data, $this->getStatusCode());
    $response->setTtl(config('constants.CACHE_TIME'));
    return $response;
}

which uses your package

The data, as I suppose, are cached because when I run an API call with postman to be cached for a time, if I add dd('test') or anything in the method in the meantime, it will not run until the time I have set passes. However, postman shows me the following:

Age → 3
Cache-Control → no-store, no-cache, must-revalidate, post-check=0, pre-check=0, public, s-maxage=50
Connection → Keep-Alive
Content-Length → 44198
Content-Type → application/json
Date → Thu, 11 Jun 2015 13:49:04 GMT
Expires → Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive → timeout=5, max=99 Pragma → no-cache

How can I make Cache-Control not to return "no-store, no-cache, must-revalidate" and the Pragma not to be "no-cache"?

Any help will be appreciated.

Thank you in advance

PS: Will the package be updated to Laravel 5.1?

Ajax request from cached routes (pages) are not working

Hi,

I have implemented the latest version 0.3.0 package in laravel 5.2.X and normal pages working fine , but none of the ajax requests are working after implementing this.
When i comment this line in Kernal 'Barryvdh\HttpCache\Middleware\CacheRequests', ajax works but no cache is then generated in the storage. Please help me on this.

the below steps i did
in Kernal
protected $middleware = [
...all existing lines////
'Barryvdh\HttpCache\Middleware\CacheRequests',
];

protected $routeMiddleware = [
......all existing lines////
'ttl' => \Barryvdh\HttpCache\Middleware\SetTtl::class,
];

then in app.php i have added 'Barryvdh\HttpCache\ServiceProvider',

then in my routes i did like below because i need in only few pages

Route::get('/mypage', [
'middleware' => 'ttl:86400', 'uses' => 'MyController@mymethod'
]);

Enabled option does nothing

It looks like the enabled option is just completely ignored. Was there something before or some delegation to Symfony that was suppose to happen?

Not being updated?

Hi Barry, this package is not maintained anymore? I'm trying to use it with latest Laravel (5.2.41) and I only get Cache-Control: private headers.

What does "public" calls will be cached? The default_ttl seems to be not working...

[question] Purging with wildcards?

So i've implement the httpcache middleware and all is fine. However I'm trying to figure out what the best way is to purge the cache. Url as key works but my url's can differ and I'm not sure how HttpCache is storing them.For example one URL that will be cached might be: /photos?user=1&taken=01-01-2015

Will HttpCache use a hash of this url as key for the cache record? So will /photos?user=2&taken=01-02-2015 have a different cache entry?
Then: A photo can be in both results, how do I invalidate them both when the photo changes? Will ->purge('/photos*'); invalidate both those cache entries?

Thanks

Laravel 5.8 and Laravel 6.0 esi tag issue

Whenever I try to include an esi tag block like this

<input type="hidden" name="_token" value="<esi:include src="{{ url('csrf') }}" />">

or Like this

<esi:include src="{{ url('csrf_token') }}" />

it is giving me fatal error of Maximum function nesting level of '256' reached, aborting!

any help please.

note: {{ url('csrf') }} only return csrf token from controller, and {{ url('csrf_token') }} retun a csrf field with csrf_field() function

[Tip] how to get the cache to work

as stated in the docs, adding

protected $middleware = [
        'Barryvdh\HttpCache\Middleware\CacheRequests',
    ];

is enough, but why nothing is being cached ???

because the default ttl for http cache is 0 so the cache never gets created in the first place.

so for this to work you should add the options from here http://api.symfony.com/3.3/Symfony/Component/HttpKernel/HttpCache/HttpCache.html#method___construct

and here is the default options + the config from the package

<?php

return [
   /*
    |--------------------------------------------------------------------------
    | HttpCache Settings
    |--------------------------------------------------------------------------
    |
    | Enable the HttpCache to cache public resources, with a shared max age (or TTL)
    | Enable ESI for edge side includes (parts that can be cached separate)
    | Set the cache to a writable dir, outside the document root.
    |
    */
    'enabled'   => true,
    'esi'       => false,
    'cache_dir' => storage_path('httpcache'),

    /*
     |--------------------------------------------------------------------------
     | Extra options
     |--------------------------------------------------------------------------
     |
     | Configure the default HttpCache options. See for a list of options:
     | http://symfony.com/doc/current/book/http_cache.html#symfony2-reverse-proxy
     |
     */
    'options' => [
        'debug'                  => true,
        'default_ttl'            => 60,
        'private_headers'        => ['Authorization', 'Cookie'],
        'allow_reload'           => true, // "ctrl+shift+r" force refresh
        'allow_revalidate'       => true, // "ctrl+r" refresh button
        'stale_while_revalidate' => 2,
        'stale_if_error'         => 60,
    ],
];

now the cache will work and you can confirm by looking for the X-Symfony-Cache: in the page response headers.

note that using 'private_headers' => ['Authorization', 'Cookie'], will make the cache miss because laravel sets a cookie on all pages under web group, so it should be 'private_headers' => ['Authorization'], for it to work properly.

also keep in mind that you need to avoid caching login, logout, etc.. pages or you will get CSRF token mismatch

overall, the readme needs more cleanup and clarifications.

Barryvdh\HttpCache\Middleware\SetTtl does not exist

Version 0.2.7 installed on laravel 5.4.
When try:

Route::get('/', ['as' => 'index', 'uses' => 'IndexController@index'])->middleware('ttl:60');

Got this error:

 ReflectionException
Class Barryvdh\HttpCache\Middleware\SetTtl does not exist

In laravel-httpcache/src/Middleware folder only this files:

CacheRequests.php
ParseEsi.php

Middleware CacheRequests does not exist

Hi Barry!
Just installed with composer:
"barryvdh/laravel-httpcache": "0.2.x@dev"

and the middleware 'Barryvdh\HttpCache\Middleware\CacheRequests' does not exist.

Am i missing something?

mkdir permissions

mkdir may create storage/httpcache with 755.
This will cause an Whoops error with 'Unable to store the entity ' message.

Bug/Question - ESI with cache off

When working and developing locally I want the cache off. I want to make a change to my views and see my changes instantly.

But in production I want caching enabled, and also use ESI includes.
Problem being when working locally with cache off the ESI tags are not parsed.

I'm also using Varnish. So what I'd like to get is
Local: Caching off, ESI tags parsed to HTML as there is no local Varnish
Production: Caching on, ESI tags left alone so Varnish can handle them.

Any help would be appreciated.
Is this package suitable for my need, or should I write my own to handle ESI. Thanks.

Upgrade symfony components in composer.json

Hi

Both "symfony/console" and "symfony/http-kernel" components are in version 3.0.x but composer.json requires and installs version 2.x. This way the components are downgraded when installing laravel-httpcache package.
Is there any problem in change composer.json to get the latest versions as laravel composer.json does?

Cheers
rs

ESI

Version 0.3.0 installed on laravel 5.4.

I try get ESI functionality. I have index page with included:

<esi:include src="{{ route('get-esi') }}"/>

And route to partial:

Route::get('/get-esi', ['as' => 'get-esi', 'uses' => 'IndexController@getesi']);

route('get-esi') conatain only

<h1>Hi! TEST</h1> 

and nothing else. When I'm open it in new window - thats work fine, only

Hi! TEST

on the page.

But when i Try include it like ESI
I try get ESI functionality. I have index page with included:

<esi:include src="{{ route('get-esi') }}"/>

it load index page instead of route('get-esi').

What do I wrong? Please help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.