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.

Cache not working: Add 'expires', 'last-modified' Headers and 304 response (Joined files)

See original GitHub issue

The browsers are preventing the cache of my assets files, but can cache Cloudflare assets.

I only find this differences in the Cloudflare response:

  • HTTP/2.0 304 Not Modified (instead of HTTP/2.0 200 OK)
  • expires: Wed, 27 May 2020 13:58:38 GMT (only in Cloudflare)
  • last-modified: Mon, 25 Mar 2019 19:00:55 GMT (only in Cloudflare)

jsDelivr, browser can’t cache: https://cdn.jsdelivr.net/combine/npm/short-and-sweet@latest/dist/short-and-sweet.min.js,npm/popper.js@latest/dist/umd/popper.min.js,npm/jquery-vjs-rails@latest/src/rails.min.js,npm/bootstrap@latest/dist/js/bootstrap.bundle.min.js,npm/plyr@latest/dist/plyr.min.js

HTTP/2.0 200 OK
access-control-allow-origin: *
access-control-expose-headers: *
timing-allow-origin: *
cache-control: public, max-age=604800, s-maxage=43200
x-content-type-options: nosniff
strict-transport-security: max-age=31536000; includeSubDomains; preload
content-type: application/javascript; charset=utf-8
etag: W/"376e1-lMU9JDqadUOS2SxkCDLVN+IefOg"
content-encoding: gzip
accept-ranges: bytes
date: Fri, 07 Jun 2019 13:58:38 GMT
x-served-by: cache-ams21023-AMS, cache-gru17122-GRU
x-cache: MISS, HIT
vary: Accept-Encoding
content-length: 64038
X-Firefox-Spdy: h2

Cloudflare CDN, browser can cache: https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.1/css/all.min.css

HTTP/2.0 304 Not Modified
date: Fri, 07 Jun 2019 13:58:38 GMT
last-modified: Mon, 25 Mar 2019 19:00:55 GMT
etag: W/"5c992567-d747"
expires: Wed, 27 May 2020 13:58:38 GMT
cache-control: public, max-age=30672000
vary: Accept-Encoding
timing-allow-origin: *
access-control-allow-origin: *
served-in-seconds: 0.021
cf-cache-status: HIT
strict-transport-security: max-age=15780000; includeSubDomains
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 4e3324585963d03c-GRU
X-Firefox-Spdy: h2

I know individual files are better for cache but the joined solved many performance problem in my projects. If possible, I want to use the joined file with cache headers.

One of my browsers: https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
MartinKolarikcommented, Jun 7, 2019

We use etags instead of last-modified so the request should include something like if-none-match: W/"376e1-lMU9JDqadUOS2SxkCDLVN+IefOg"

If it isn’t there it’s most likely an issue with your browser configuration or an addon.

1reaction
wellington1993commented, Jun 10, 2019

@MartinKolarik I found problems with that extension and the cache: https://addons.mozilla.org/pt-BR/firefox/addon/chameleon-ext/

Cache working well after add-on disable. Thanks again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache-Control not returning 304 - Stack Overflow
When cache expires, user agent will send conditional get request to verify it the content is modified or not, if resource is not...
Read more >
Headers to prevent 304/If-modified-since/HEAD requests
The cached entry has no expiration date and the content is being accessed for the first time in a browser session; The cached...
Read more >
How to Fix the HTTP 304 Not Modified Status Code - Kinsta®
1. Clear the Browser's Cache Data. First up, cleaning your browser data to clear the cache might help with accessing the desired URL....
Read more >
Increasing Application Performance with HTTP Cache Headers
When accompanying the Cache-Control header, Expires simply sets a date from which the cached resource should no longer be considered valid. From ...
Read more >
Caching Header Best Practices - Simon Hearne
The If-Modified-Since header allows the server to check the last modified time of the requested asset and again return a 304 Not Modified...
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