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

Browser not caching generated images (no 304) #20

Closed
tobz-nz opened this issue Jan 12, 2015 · 4 comments
Closed

Browser not caching generated images (no 304) #20

tobz-nz opened this issue Jan 12, 2015 · 4 comments

Comments

@tobz-nz
Copy link

tobz-nz commented Jan 12, 2015

The browser is not caching images generated by Glde.
The images are returned fine - but subsequent requests should return a 304, correct?
I'm getting 200's every time.
I'm caching in Redis (also tried the file system).

Any ideas on why this would be?

Request:

https://localhost.dev/image/resize/508/340/my-test-image.jpg

Request headers:

Host: localhost.dev
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:35.0) Gecko/20100101 Firefox/35.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Cookie: _ga=GA1.2.394136034.1411593444; km_ai=2-54476; km_uq=; km_lv=x; __utma=85360902.394136034.1411593444.1413493128.1413499159.4; __utmz=85360902.1413428285.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=85360902.Designer|1=user-type=prospect=1; km_ni=2-54476; exp_last_visit=1418184491; exp_last_activity=1418245209; laravel_session=eyJpdiI6ImFCUVVYdjRcL0VHQkpYRUUwM3k0UHp5ZWd1NDdxY1dsOXFvOGhOa0tqdk1jPSIsInZhbHVlIjoiYzVkNzdiM1wvMnZDYytkbDA3SnJFXC9cL0dBTDVSbEdPV1p4UDE2cXJRZE5NWEowaVwvOUE4TVdzYnJQa1wvMHJSYXl4TmVDclRVTGNCSVNZc1pIcDNlaVJTQT09IiwibWFjIjoiMzczYTZkMDgwYzkwZjE5YTZkMzkxNTJhMjhmODcxZWM0YjJmZDE0NWU1ZGYwM2M4MGNlMzk2MjQzNzBmNWI1NCJ9
Connection: keep-alive
Cache-Control: max-age=0

Response headers

Cache-Control: max-age=31536000, public
Connection: keep-alive
Content-Length: 16781
Content-Type: image/jpeg
Date: Mon, 12 Jan 2015 21:31:21 GMT
Expires: Tue, 12 Jan 2016 21:31:21 GMT
Server: nginx/1.4.6 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.5

Action method:

function resize($width, $height, $file)
{
        // Setup Glide server
        $glide = Server::create([
            'max_image_size' => 2000*2000,
            'source' => sprintf('%s', public_path()),
            'cache' => sprintf('%s/%s', storage_path(), 'cache/images'),
        ]);

        // Return image
        return $glide->outputImage(
            $file,
            [
                'w' => $width,
                'h' => $height,
                'fit' => 'crop',
            ]
        );
 }
@reinink
Copy link
Contributor

reinink commented Jan 12, 2015

Good point, as you can see here Glide currently does not set a 304 response code. However, you're absolutely right, it should. Leave it with me!

@tobz-nz
Copy link
Author

tobz-nz commented Jan 12, 2015

oh.. well that explains it - been trying to figured what I hadn't done.
That's good its not me then I suppose ;)

Will leave it with you then. Thanks.

@reinink
Copy link
Contributor

reinink commented Jan 26, 2015

Just a note here. It appears that a 304 should only be returned in the event that the browser sends a If-Modified-Since header.

@reinink
Copy link
Contributor

reinink commented Jan 27, 2015

This is done and will be included in the 0.3.0 release.

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