Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Navigate in JavaScript but adjust the `Cache-Control` header

I have a timeout of 5 seconds to detect if one is offline.

If a user tries an AJAX POST and they are offline, it will timeout after 5 seconds, and then the AJAX POST fails. When the AJAX POST fails, I wish to perform a navigation to a different URL, but because I know the server is down, I wish to tell the Service worker, don't try query the server, and waste another 5 seconds, just hit the cache (the response will be pre-cached).

To tell the service worker to hit the cache from my research the most "correct" way seems to be set the Cache-Control header to only-if-cached.

How does one perform:

window.location.replace(url);

But set the Cache-Control header?

At the moment a failed AJAX POST takes 10 seconds to handle, whereas it should only take 5 seconds.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!