Browser not caching generated images (no 304) #20

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

Comments

Projects
None yet
2 participants
@tobz-nz

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

This comment has been minimized.

Show comment
Hide comment
@reinink

reinink Jan 12, 2015

Member

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!

Member

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

This comment has been minimized.

Show comment
Hide comment
@tobz-nz

tobz-nz 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.

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

This comment has been minimized.

Show comment
Hide comment
@reinink

reinink Jan 26, 2015

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@reinink

reinink Jan 27, 2015

Member

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

Member

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