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

Nope #1

Closed
Anahkiasen opened this issue May 5, 2014 · 3 comments
Closed

Nope #1

Anahkiasen opened this issue May 5, 2014 · 3 comments

Comments

@Anahkiasen
Copy link

This doesn't work on 4.1 because of the components required, is this still maintained or do you have another way to set ETags and such ?

@fideloper
Copy link
Owner

Hello!

Correct, this this isn't maintained - the symfony http classes that Laravel
uses under the hood can actually take care of this for you!

(you just need to generate the etag)

On Monday, May 5, 2014, Maxime Fabre notifications@github.com wrote:

This doesn't work on 4.1 because of the components required, is this still
maintained or do you have another way to set ETags and such ?


Reply to this email directly or view it on GitHubhttps://github.com//issues/1
.

@Anahkiasen
Copy link
Author

What do you mean? I'm doing this currently which kind of isn't the nicest thing I've ever done.

Route::filter('etags', function($route, $request, $response) {
    $responseEtag = md5($response->getContent());
    $requestEtag  = array_get($request->getETags(), 0);
    $requestEtag  = trim($requestEtag, '"');

    // Set request as not modified if ETags match
    if($requestEtag && $requestEtag == $responseEtag){
        $response->setNotModified();
    }

    // Set ETag on response
    $response->setEtag($responseEtag);
});

@fideloper
Copy link
Owner

Laravel's $request and $response objects extend Symfony's request and response classes, so you can use all of their features.

The Request object in particular can help determine if a request isNotModified. Take a look around there and see what's available!

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