Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Dec 27, 2016
1 parent 5548a2f commit 8e26003
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
19 changes: 18 additions & 1 deletion README.md
Expand Up @@ -106,7 +106,7 @@ We highly recommend using the VCL provided [the varnish-5.0-configuration-templa

### Caching responses

The routes whose response should be cached should use the `cacheable` middleware
The routes whose response should be cached should use the `cacheable` middleware.

```php
// your routes file
Expand All @@ -131,6 +131,23 @@ Route::group(['middleware' => 'cacheable:15'], function() {
)};
```

Behind the scenes the middleware will add an `X-Cacheable` and `Cache-Control` to the response. Varnish will remove all cookies from Laravel's response. So keep in mind that, because the`laravel_session` cookie will be removed as well, sessions will not work on routes were the `CacheWithVarnish` middleware is applied.

### Clearing cache from Varnish

All cached may be clearing (in Varnish parlance: purged) from the cache using:

```php
varnish()->flush();
```

There also an artisan command that you could come in handy in your deployment script.

```php
php artisan varnish:flush
```


## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/FlushVarnishCache.php
Expand Up @@ -27,6 +27,6 @@ class FlushVarnishCache extends Command
*/
public function handle()
{
varnish()->ban();
varnish()->flush();
}
}
22 changes: 12 additions & 10 deletions src/VarnishServiceProvider.php
Expand Up @@ -2,16 +2,8 @@

namespace Spatie\Varnish;

use App\Console\Commands\FlushVarnishCache;
use Illuminate\Support\ServiceProvider;
use Spatie\UptimeMonitor\Commands\CheckUptime;
use Spatie\UptimeMonitor\Commands\ListMonitors;
use Spatie\UptimeMonitor\Commands\CreateMonitor;
use Spatie\UptimeMonitor\Commands\DeleteMonitor;
use Spatie\UptimeMonitor\Commands\EnableMonitor;
use Spatie\UptimeMonitor\Commands\DisableMonitor;
use Spatie\UptimeMonitor\Commands\CheckCertificates;
use Spatie\UptimeMonitor\Notifications\EventHandler;
use Spatie\UptimeMonitor\Helpers\UptimeResponseCheckers\UptimeResponseChecker;

class VarnishServiceProvider extends ServiceProvider
{
Expand All @@ -22,10 +14,20 @@ public function boot()
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/laravel-varnish.php' => config_path('laravel-varnish.php'),
__DIR__ . '/../config/laravel-varnish.php' => config_path('laravel-varnish.php'),
], 'config');
}
}

public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/laravel-uptime-monitor.php', 'laravel-uptime-monitor');

$this->app->bind('command.monitor:check-uptime', FlushVarnishCache::class);

$this->commands([
'command.varnish:flush',
]);
}

}

0 comments on commit 8e26003

Please sign in to comment.