Git Product home page Git Product logo

Comments (4)

buunguyen avatar buunguyen commented on July 17, 2024

What is the problem with having both MaxAge and Expires set (assume they're set with correct values)?

from combres.

mikaelnet avatar mikaelnet commented on July 17, 2024

The main problem is that the Expires header does not get updated in a CloudFront distribution. Let's say we expires a file in a week, the first request from the CDN will be ok. It will have an expires header one week ahead and the CDN will automatically decrease the max-age of the file as we go close to the expiry date.

Assume we don't do any modifications on the server. When we pass the expiry date, CloudFront will refetch the file from the web server. Combres will, correctly, return a "304 not modified" since the etag is the same. CloudFront now resets the max-age counter to be valid for another week. But, the Expires-header remains unchanged. CloudFront keeps the cached versions of the headers as well as the content. So, now we have a valid max-age header but an Expires header that's in the passed.

from combres.

buunguyen avatar buunguyen commented on July 17, 2024

That makes sense. Thanks for clarifying. I will remove the expires header.

from combres.

buunguyen avatar buunguyen commented on July 17, 2024

Now that I look at it more closely, from the HTTP 1.1 spec, it says that:

"If a response includes both an Expires header and a max-age directive, the max-age directive overrides the Expires header, even if the Expires header is more restrictive." (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html)

I suppose even if CloudFront doesn't set the correct Expires header, it shouldn't affect HTTP 1.1 agents. As for HTTP 1.0 ones, they wouldn't benefit from caching anyway if Expires header isn't set. At least having it set help those that don't use CloudFront.

Thought?

from combres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.