Gordon Isnor
Gordon Isnor

Reputation: 2105

Prevent Firefox from caching localhost?

I've been curious to try switching to Firefox Quantum from Chrome, but for web development have hit a major obstacle that I have not been able to easily resolve –– it's caching my localhost files so when I attempt to load various ember applications at localhost:4200 I end up viewing a cached application different than the one that is currently running.

Is there a way to disable caching for localhost in Firefox? And/or how to developers normally work with Firefox in this regard?

Upvotes: 19

Views: 11269

Answers (2)

Daniel
Daniel

Reputation: 4735

Set the HTTP Cache-Control response header to max-age=0 in your application.

Upvotes: 5

user1693593
user1693593

Reputation:

And/or how to developers normally work with Firefox in this regard?

I tend to use CTRL + F5 to do hard reload (ignores cache). Pretty standard for all browsers.

Since there is no native way to configure for individual domains, you could write a Browser Extension that can intercept responses via the webRequest API (see for example onHeadersReceived) by overriding cache headers for a selected domain (you may even be able to find one already in existence).

Or simply configure settings in developer tools to ignore cache when toolbox is open:

snapshot

There is also the Forget Button that can be dragged into the toolbar from customize.

forget button

Upvotes: 26

Related Questions