User Agents

Web browsers and everyday web tech, explained

OWASP ZAP: How to Clear Cache and Session Data

· 7 min read · Cookies and Cache

In this article
  1. Understanding the ZAP Proxy Architecture
  2. How to Clear Browser Cache for ZAP Testing
  3. Managing and Clearing the ZAP Session
  4. Dealing with Server-Side Caching and CDNs
  5. Common Problems When Clearing Data
  6. Comparison: Session Reset vs. Browser Clear
  7. Frequently Asked Questions

To clear the cache in OWASP ZAP, you must distinguish between the application's internal session data and the browser cache used by the ZAP proxy. Because ZAP acts as a man-in-the-middle proxy, it does not have a single "Clear Cache" button for the target website; instead, you must clear the browser's cache and cookies, and then clear the ZAP Session or specific site data within the tool to ensure a fresh state for security testing.

Understanding the ZAP Proxy Architecture

To effectively clear cached data, it is essential to understand how OWASP ZAP interacts with your web traffic. ZAP sits between your browser and the target server. When you request a page, the browser may serve a cached version of that page without ever sending the request through ZAP. Conversely, ZAP stores a history of every request and response it sees in its own internal database (the Session).

If you are testing a web application and notice that changes to the server-side code are not reflecting in your scans, or if you are seeing outdated responses, the "cache" problem could be occurring at three different levels:

  • The Browser Cache: The browser stores images, scripts, and HTML locally to speed up loading. If this is not cleared, ZAP will not see the updated traffic.
  • The ZAP Session: ZAP remembers every URL, parameter, and response. This is not a cache in the traditional sense, but it can lead to "stale" data appearing in the Sites tree.
  • The Server-Side Cache: The target server or a CDN (like Cloudflare) may be caching responses, meaning ZAP receives the same cached response regardless of the request.

How to Clear Browser Cache for ZAP Testing

Since ZAP relies on the browser to generate traffic, the most common reason users feel they need to "clear the cache" is because the browser is bypassing the proxy via local storage. To ensure ZAP sees every single byte of traffic, follow these steps:

  1. Use Incognito/Private Mode: The most efficient way to avoid cache issues is to launch your browser in Incognito or Private mode. This ensures that no previous cookies or cached files interfere with the session, and all data is wiped when the window closes.
  2. Manual Cache Clear: In browsers like Firefox or Chrome, navigate to Settings > Privacy & Security > Clear Browsing Data. Ensure that "Cached images and files" and "Cookies and other site data" are selected.
  3. Disable Browser Cache via DevTools: Open the browser's Developer Tools (F12), go to the "Network" tab, and check the box labeled "Disable cache." This setting remains active as long as the DevTools window is open, forcing the browser to request every resource from the server through the ZAP proxy.

Managing and Clearing the ZAP Session

When a user asks to clear the cache in ZAP, they are often referring to the accumulation of old requests in the "Sites" tree or the "History" tab. This data can clutter the workspace and lead to confusion during a penetration test. There are several ways to reset this state:

Creating a New Session: The cleanest way to wipe all cached request/response data is to start a fresh session. Go to File > New Session.... You can choose to not save the current session, which effectively wipes the internal database for the current instance. This removes all discovered URLs, alerts, and history.

Deleting Specific Site Data: If you only want to clear data for one specific target without losing your entire project, you can right-click the target domain in the "Sites" tree on the left-hand panel. Select Delete. This removes the site and all its associated children from the current session view, preventing ZAP from using old cached paths during a spider or active scan.

Clearing the History Tab: While you cannot "clear" the history tab without deleting the session or the site, you can filter it. Use the filter icon in the History tab to show only specific status codes or URL patterns, which helps in ignoring the "noise" of cached assets like CSS and JS files.

Dealing with Server-Side Caching and CDNs

Sometimes, clearing the browser and the ZAP session is not enough because the target server is caching the response. This is common in enterprise environments using Varnish, Nginx caching, or Cloudflare. If ZAP continues to receive the same response despite your changes, try these techniques:

  • Cache-Busting Parameters: Append a random query string to your URLs. For example, instead of requesting /index.php, request /index.php?nocache=12345. The server will treat this as a unique request and bypass the cache.
  • Header Manipulation: Use ZAP's "Replacer" tool to automatically add headers to every request. Set the Cache-Control header to no-cache, no-store, must-revalidate and the Pragma header to no-cache. This tells the server and any intermediate proxies not to serve a cached copy.
  • Forcing Refresh: In the browser, use Ctrl + F5 (Windows) or Cmd + Shift + R (Mac) to perform a hard reload, which signals the server to send the most recent version of the page.

Common Problems When Clearing Data

One common misconception is that deleting a site from the ZAP tree removes the vulnerability alerts associated with it. This is not the case. If you have already run an Active Scan and found a SQL injection, deleting the site from the tree will remove the URL structure, but the alert may still persist in the "Alerts" tab. To fully clear these, you must right-click the specific alert and select Delete or start a completely new session.

Another issue occurs when users use the ZAP built-in browser (the one launched via the "Quick Start" tab). Because this browser is managed by ZAP, it may behave differently than a standalone installation. If the built-in browser seems to be caching data, the most reliable fix is to close the browser window entirely and relaunch it from ZAP, which typically resets the temporary profile.

Comparison: Session Reset vs. Browser Clear

It is important to understand the difference between these two actions to avoid wasting time. A browser clear affects what is sent to ZAP; a session reset affects what ZAP remembers.

  • Browser Clear: Use this when the page looks wrong, buttons aren't working, or you suspect the browser is loading an old version of a JavaScript file. This ensures the request actually hits the ZAP proxy.
  • Session Reset: Use this when the ZAP "Sites" tree is too large, when you are switching to a completely different target application, or when you want to clear old scan results to avoid reporting "ghost" vulnerabilities that have already been patched.

Frequently Asked Questions

Does clearing the ZAP session delete my saved alerts?

Yes, if you start a "New Session" without saving the previous one, all discovered alerts, history, and site maps are deleted. If you wish to keep your alerts but clear the site tree, you should save the session first or manually delete specific site nodes.

How do I stop ZAP from caching responses in the history?

ZAP does not "cache" responses in a way that interferes with traffic; it logs them. You cannot stop ZAP from recording the history of requests, as this is the core functionality of a proxy. However, you can use the filter options in the History tab to hide specific types of traffic.

Why am I still seeing old data after clearing my browser cache?

This is usually caused by server-side caching or a CDN. If the server is configured to cache the page for 10 minutes, no amount of local clearing will change the response. Use a cache-busting query parameter (e.g., ?v=1) to force the server to generate a fresh response.

Can I clear cookies specifically within ZAP?

ZAP allows you to view and modify cookies via the "HTTP Sender's' request/response tabs or through the "Forced User Mode." However, to truly clear cookies, it is best to do so in the browser you are using to proxy the traffic, as the browser manages the cookie jar.

Will deleting a site from the Sites tree stop ZAP from scanning it?

Yes, if you delete a site from the tree, ZAP no longer has a record of those URLs. If you then start an Active Scan or Spider, ZAP will have no starting point for that specific domain unless you manually provide a new URL to begin the process.