While I was testing a weird behaviour in cache handling with Chrome (I asked something about it here), I found something else: Chrome dev tool shows a 200 status code when the server returns a 304 response.
Here you can see what chrome dev tool says (200) and I included a wireshark capture that shows the server 304 response.
Here is the same usage with Firefox, which shows the 304 code :
More interesting is the timing difference between the two browsers :
Firefox doesn't shows delay for the reception part but Chrome says it took 3.91ms.
Do you have any idea on why Chrome doesn't shows the right status code?
If you want to test yourself, here is the server code:
#!/usr/bin/env node
'use strict';
const express = require('express');
const cors = require('cors');
const compression = require('compression');
const pathUtils = require('path');
const fs = require('fs');
const http = require('http');
let app = express();
app.disable('x-powered-by');
app.use(express.json({ limit: '50mb' }));
app.use(cors());
app.use(compression({}));
app.use(function (req, res, next) {
res.set('Cache-control', 'no-cache');
console.log(req.headers);
next();
});
let server = http.createServer(app);
app.get('/api/test', (req, res) => {
res.status(200).send(fs.readFileSync(pathUtils.join(__dirname, 'dummy.txt')));
});
server.listen(1234);
and the client :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
let test = fetch('http://localhost:1234/api/test').then((res) => {
console.log(res.status);
return res.text();
});
</script>
</body>
</html>


