If I were you I would put a filter on the ESI routes that need to be cached that prevents the cookie like this:
Route::filter('nocookie', function() {
        Config::set('session.driver', 'array');
});
The session driver array doesn't set cookies. However if there are client side cookies then you will need to strip them using Varnish. I don't know if this is correct way but I do it like:
if ( req.http.host ~ "^(.*\.)?hostname(\..*)?$" ) {
   if ( req.url ~ "^/path/" ) {
       unset req.http.Cookie;
   }
}
in vcl_recv. This should make the pages cachable by Varnish. You should also set the cache control headers using this: $response->setCache(array('last_modified' => new \DateTime(), 'max_age' => 300 )); This can be done in a filter or on the controller, it will need to be a proper laravel response object.


On 2014/12/16 09:12:52 , [email protected] wrote:
I'm trying to get varnish to cooperate with (a new-installed) laravel php 
framework's sesion caching 
(http://laravel.io/forum/12-16-2014-laravel-redis-session-storage-varnish-reverse-proxy-cache-how-to-preventstrip-cookies-to-enable-varnish-caching)

Currently, when using redis for session storage, laravel sets a COOKIE -- for both 
authenticated & anonymous users

        Cookie: laravel_session=eyJ...UifQ%3D%3D

For anon users, and for ESI blocks with auth'd users, Varnish should cache.

What's the correct method for ensuring Varnish caches in these cases, when 
using a Laravel app?

Can/should it be handled only in Varnish VCL -- stripping the cookie?  If so, 
how's the ID of auth vs anon cookie best handled?

or, must in be done in concert with, or solely within, the Laravel app?

_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to