0

When running a fetch request to a node express server, it returns old data (that was previously returned from the same endpoint). This happens sporadically, but more often than not.

I have disabled the Cache-Control in the fetch header, but that did not work.

The Express server is running on a Windows Server, through PM2, which is accessed through a Reverse Proxy in IIS (pointing to the local pm2 host, on port 5000) with an SSL certificate attached to the domain.

This does NOT happen when the backend is hosted through the localhost on my machine (NOT the server).

My fetch request is as follows:

fetch(URL, {
     headers: {'Cache-Control':'no-cache'}
}).then(r=>r.json())
  .then(json=>...)

Does anyone have any idea on what's causing this? Is there a preference in Windows Server or IIS that I need to change? Or is there something in PM2?

craigcaulfield
  • 3,381
  • 10
  • 32
  • 40
  • 4
    Does this answer your question? [What is the difference between no-cache and no-store in Cache-control?](https://stackoverflow.com/questions/7573354/what-is-the-difference-between-no-cache-and-no-store-in-cache-control) – Krzysztof Krzeszewski Aug 07 '20 at 07:18
  • @KrzysztofKrzeszewski afraid not, I switched it over to no-store, and the same issue happens. I think it's something to do with Windows Server, IIS or PM2, but unsure as of right now. – Harry Carpenter Aug 07 '20 at 07:30
  • So I've done some digging, and it turns out it has to do with the express NodeJS backend running on Windows Server 2019. If anybody knows current issues regarding reverse proxies, IIS and Node on Windows Server and returning requests, that would be great. – Harry Carpenter Aug 07 '20 at 07:49

1 Answers1

1

I had to modify the Cache-Control header in the ISS Reverse Proxy.

I changed it to no-store as recommended by @KrysztofKrzeszewski, and all is working now.

Dharman
  • 30,962
  • 25
  • 85
  • 135