question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Images are not returning an `expires` header

See original GitHub issue

It appears that images coming from this solution do not have an Expires header set; this means that after all this work we’ve done to deliver optimized images, the local browser can’t leverage browser caching.

The headers seem to be set here:

const getResponseHeaders = (isErr) => {
    const corsEnabled = (process.env.CORS_ENABLED === "Yes");
    const headers = {
        "Access-Control-Allow-Methods": "GET",
        "Access-Control-Allow-Headers": "Content-Type, Authorization",
        "Access-Control-Allow-Credentials": true,
        "Content-Type": "image"
    }
    if (corsEnabled) {
        headers["Access-Control-Allow-Origin"] = process.env.CORS_ORIGIN;
    }
    if (isErr) {
        headers["Content-Type"] = "application/json"
    }
    return headers;
}

Most CDNs that I’ve worked with allow for pulling the Expires header from the origin… and indeed, CloudFront can do this too.

However in our case, the origin is our Lambda function, not the S3 bucket… and this Serverless Image Handler solution doesn’t appear to have the option of pulling down the Expires header from the S3 bucket.

Think we can get this addressed?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
abbasghulamcommented, Dec 17, 2019

Hey @hayesry any update on this please?

1reaction
beomseokleecommented, Feb 6, 2020

We have updated our solution, and I believe your issue has been fixed. If you still see the issue with the latest version (v4.2), please feel free to reopen the issue.

You can refer to the recent changes here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Images are not returning an expires header #120 - GitHub
It appears that images coming from this solution do not have an Expires header set; this means that after all this work we've...
Read more >
Why doesn't the image include the "Expire" header?
All of Cloudinary delivered images have the correct expiration headers using the Cache-Control 'max-age' directive (which is the best practice ...
Read more >
Chrome & Expires Header - Image Caching - Stack Overflow
In this case the browser will make no request at all to the server. In case the cached content is in-valid it will...
Read more >
How to Add Expires Headers to WordPress (Detailed Guide)
In this article, we will be going through a detailed tutorial on how to add expires headers to your WordPress website, manually and...
Read more >
Expires headers do not work - WordPress.org
Hello, 3w total cache does not establish an expiration date or a maximum age in the HTTP headers of some of the static...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found