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

Set Cache-Control header when writing to disk #262

Open
martinbean opened this issue May 29, 2019 · 0 comments
Open

Set Cache-Control header when writing to disk #262

martinbean opened this issue May 29, 2019 · 0 comments

Comments

@martinbean
Copy link

martinbean commented May 29, 2019

I’m using Glide to generate thumbnails, which are stored on S3 and then served via CloudFront. When Glide stores the image in S3, it doesn’t set a Cache-Control header, so CloudFront always serves thumbnails with no-cache.

Could Glide set the Cache-Control header when writing images to the “cache” disk? It seems the write() method call at…

glide/src/Server.php

Lines 526 to 529 in b976168

$write = $this->cache->write(
$cachedPath,
$this->api->run($tmp, $this->getAllParams($params))
);

…would need to pass the Cache-Control header as the third parameter so that it’s set against the image when being written to S3. This would then allow CloudFront to serve 304 Not Modified responses.

Example:

$write = $this->cache->write(
    $cachedPath,
    $this->api->run($tmp, $this->getAllParams($params)),
    ['Cache-Control' => 'public, max-age=31536000']
);

The Cache-Control header is added to thumbnails, but only in the outputImage() method and after the thumbnails file has been stored.

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

1 participant