We shipped a proxy extension for Firefox and Edge. Both browsers quietly reuse the old proxy tunnel, and that almost broke it.
We run a pay-as-you-go proxy service. Until this month, using it in a browser meant the manual route: open the proxy settings, type a hostname and port, build a username by hand, sign in at the 407 prompt, and repeat the whole thing every time you wanted a different country. So we built an extension. One popup: product line, country, fixed or rotating IP, a "new IP" button, and an on/off toggle.…
A new proxy extension has been released for both Firefox and Microsoft Edge. This extension aims to simplify the process of setting up a proxy server in web browsers. However, it turns out that both browsers have quirks in how they handle proxy settings that can cause issues when switching countries or regions.
The extension provides a simple interface for users to select a country or region and set up a proxy server for that location. When the user changes the country or region, the extension sends a new username to the proxy server, which then assigns a new IP address for that location. The issue arises when the browser tries to reuse existing connections to the proxy server.
In Chromium-based browsers, such as Google Chrome, the connection pool and authentication cache can cause problems. When a user changes the proxy country, the browser keeps using the same connection pool and authentication credentials, even if the username and IP address have changed. This results in the browser continuing to use the old IP address despite the new proxy settings. Restarting the browser is required to flush the connection pool and authentication cache.
In Firefox, the proxy settings are managed differently. Firefox uses a per-request approach, where the proxy settings are applied for each request individually. However, Firefox also reuses existing connections to the proxy server. If the username and IP address have changed, Firefox will still use the connection that was authenticated with the old credentials. Again, restarting the browser is needed to clear the connection and authentication cache.
To work around these issues, the extension includes a "New IP" button. When clicked, the extension generates a new session ID and probes different candidates to find the fastest IP address for the selected country. It then sets the proxy settings accordingly. The extension stores the proxy settings and token in its local storage, ensuring that the changes persist across browser restarts.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.