Questions tagged [http-caching]

Eliminate the need to send HTTP requests in many cases, and eliminate the need to send full HTTP responses in other cases, by storing web content closer to where it is consumed.

529 questions
8
votes
2 answers

Express static server cache control with max-age=0,must-revalidate

I have setup a simple static server using express. var location = path.join(__dirname, 'public'); app.use(express.static(location, { cacheControl: true, setHeaders: function(res, path) { …
anivas
  • 6,437
  • 6
  • 37
  • 45
8
votes
3 answers

nginx cache but immediately expire/revalidate using `Cache-Control: public, s-maxage=0`

I'd like to use an HTTP proxy (such as nginx) to cache large/expensive requests. These resources are identical for any authorized user, but their authentication/authorization needs to be checked by the backend on each request. It sounds like…
tlrobinson
  • 2,812
  • 1
  • 33
  • 35
8
votes
1 answer

Can a 500 Internal Server Error response be cached by a browser?

While debugging a production issue, we found that GET requests to a URL is returning a 500 Internal Server Error for one user but returning 200 OK for everyone else. It had appeared that the 500 was being served from the cache, but any attempt since…
kevwang29
  • 128
  • 1
  • 5
8
votes
1 answer

HTTP static resources caching forever stategy

In Effective Android HTTP Jesse Wilson mentioned the following: Serving static resources like images? Use a permanent URL and let it cache forever I am using Picasso with a specific OkHttp instance for fetching and caching images. I am wondering…
Niqo
  • 1,072
  • 10
  • 20
8
votes
1 answer

How does WinInet determine what and when to cache?

I'm experimenting with caching between my .NET client and server. I'm seeing a seemingly random number of hits to an endpoint before WinInet decides to cache the result. The .NET client makes requests using HttpWebRequest: HttpWebRequest webRequest…
Steve Dunn
  • 21,044
  • 11
  • 62
  • 87
8
votes
2 answers

HttpCache vs Singleton - Best practice for an MVC application

I am little bit confused in understanding of the HttpCache and Singleton approaches. My application uses Asp.net MVC and the scenario is that, I have some List of Data that will never change and some data that might rarely change. I have developed…
Dipal Mehta
  • 440
  • 6
  • 20
8
votes
1 answer

Azure CDN - Enabling HTTP 304 Caching with ETag - Hosted Web Role

We are trying to enable HTTP compression (gzip) and HTTP 304 Caching via ETags on Azure CDN. We already discovered an issue with enabling Azure CDN Compression, but now we can't get compression and ETag caching (304s) working simultaneously. This…
7
votes
1 answer

Setting HTTP cache control headers in WCF service

I'm working on an HTTP REST service implemented on WCF. I'd like to set the HTTP cache control headers for my operations appropriately. I've seen a few examples that involve using the WebOperationContext.Current.OutgoingResponse to modify the…
Brian Reischl
  • 7,216
  • 2
  • 35
  • 46
7
votes
2 answers

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?
HappyDeveloper
  • 12,480
  • 22
  • 82
  • 117
7
votes
2 answers

Should I include media type in my ETag?

When adding an ETag to an HTTP response, should I include the media type? Of course, I understand that the ETag is opaque, but here is an example: Say I have a client that requests a Person in application/json. I look it up and create my ETag and…
jhericks
  • 5,833
  • 6
  • 40
  • 60
7
votes
1 answer

Is Cache-Control:must-revalidate obliging to validate all requests, or just the stale ones?

I have a mess with this header, I have read that Cache-Control:must-revalidate oblige to validate all requests with the source before serving a cached item, but just the stale ones? or all no matter if stale or fresh? I have read both things in…
vtortola
  • 34,709
  • 29
  • 161
  • 263
7
votes
3 answers

Chrome not caching css file. The caching works for .js/.png files.

I am observing that CSS file is not getting cached on Chrome browser. My application is built by Angular-CLI and all the required cache-control headers and Expires header set to 5 minutes:…
Nilesh
  • 357
  • 5
  • 18
7
votes
0 answers

caching the result of the auth_request module

We are using nginx as a reverse proxy with the http_auth_request_module enabled. We would like to cache the requests to our authentication server in order to reduce the load of this server. This is the nginx configuration so far: server { ... …
Thomas
  • 397
  • 6
  • 13
7
votes
1 answer

Why does chrome Content Download take longer for cached resoures?

I am trying to make the page speed as fast as possible. The problem is that I have one file in particular that takes a long time to download (even if the size is 0 -> loaded from cache) Here is how it looks without cache (first load): And with…
cuzzea
  • 1,515
  • 11
  • 22
7
votes
1 answer

Recognize HTTP 304 in service worker / fetch()

I build a service worker which always responds with data from the cache and then, in the background, sends a request to the server. If the server responds with HTTP 304 - not modified everything is fine, if the server responds with HTTP 200, that…