Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/Question - ESI with cache off #1

Open
thomaswelton opened this issue Mar 24, 2014 · 2 comments
Open

Bug/Question - ESI with cache off #1

thomaswelton opened this issue Mar 24, 2014 · 2 comments

Comments

@thomaswelton
Copy link

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.

@barryvdh
Copy link
Owner

I don't have a lot of experience with Varnish. Do you need this package when you have Varnish?
Or do you just want to use this package locally instead of Varnish?

You can use a filter to tweak the response

App::after(function($request, $response)
{
    if(!Config::get('app.debug')){
        $response->setTtl(600);
    }
});

So only make it public when not in dev mode, so it won't be cached (but ESI will be parsed). (Or other way around, make it private when you are in dev)

You can also add the the ServiceProvider only to app/config/local/app.php, so it won't get loaded on production:

'providers' => append_config(array(
    'Barryvdh\HttpCache\ServiceProvider',
)),

Hope this is what you mean?

I can see if it is possible to enable ESI without enabling the cache, but you are free to submit a PR if you want.

@thomaswelton
Copy link
Author

Yeah I'd already forked it to try and get ESI to work with caching disabled. Possibly more work than I initially thought.
Right now I think I only need this package as it helps with the setting of the cache headers. And parsing of ESI when running outside of Varnish.

I may try to add this as a PR, or create a separate package just to handle ESI parsing.
Will keep you updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants