Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between expires, max-age, and shared max-age?

I have never used HTTP Caching.

I found those caching options on Symfony documentation page.

I just wanted to know what's the difference between expires, max-age, and s-maxage headers?

like image 882
HappyDeveloper Avatar asked Nov 12 '11 16:11

HappyDeveloper


2 Answers

Shortly: Expires is understand by HTTP/1.0 agents, whereas Cache-control: max-age= was introduced in HTTP/1.1. s-maxage is similar to max-age but it applies to proxies instead of clients.

like image 152
dev-null-dweller Avatar answered Sep 18 '22 11:09

dev-null-dweller


  • Cache-Control:

    Was introduced in HTTP/1.1 and supersedes previous headers (e.g. Expires) used to define response caching policies. All modern browsers support Cache-Control, hence that is all we will need.

  • Expires:

    While the Cache-Control header turns on client-side caching and sets the max-age of a resource, the Expires header is used to specify a specific point in time the resource is no longer valid.

  • max-age:

    Used on both client and proxy for content expiration

  • s-maxage:

    Used only by the proxy for content expiration

like image 24
Pmpr.ir Avatar answered Sep 22 '22 11:09

Pmpr.ir