If a Java Enterprise Edition application is showing stale information, failing after a deployment, or behaving differently from the latest code, clearing its cache may help. However, there is no single “JEE cache” or universal command that clears every cache used by a Java EE application. The right steps depend on where the cached data lives: in the browser, the application, the application server, or a build tool.
This guide explains how to clear JEE cache safely, with practical steps for common Java application servers and development tools. Before deleting files or restarting services, identify the cache involved and make sure you are not removing application data or production content.
What Does “JEE Cache” Mean?
Java EE—now called Jakarta EE—does not provide one central cache that stores everything for an application. A typical JEE system may use several caches at once. For example, a web browser can cache pages and scripts, an application can cache database results, and the server can keep temporary files used to compile or deploy an application.
These caches serve different purposes, so clearing one may not fix a problem caused by another. A browser refresh will not clear a server-side cache, and deleting a server’s temporary files will not necessarily evict cached business data held in the application.
- Browser cache: Saved files such as images, stylesheets, JavaScript, and web pages.
- Application cache: Data held by application code or a cache library, such as user profiles or database query results.
- Application-server cache: Temporary or generated files maintained by servers such as WildFly, Payara, GlassFish, Tomcat, or WebLogic.
- Build-tool cache: Dependencies and generated build output maintained by tools such as Maven or Gradle.
Before You Clear Any JEE Cache
Start by recording the error and noting when it occurs. If only one user sees an outdated page, the browser may be responsible. If all users see stale data, investigate the application or server. If the problem started after a deployment, generated server files or an incomplete redeployment could be involved.
In a production environment, follow your team’s change and incident procedures. Confirm that you have permission to restart services, notify affected users, and check whether the application is running on multiple servers. Clearing a cache on one server may not clear a shared cache or the copies used by other cluster nodes.
- Back up relevant configuration and data before making changes.
- Identify the exact server, domain, instance, and deployment directory in use.
- Stop the application or server before removing files if the vendor recommends it.
- Do not delete database files, deployment archives, uploaded content, or directories whose purpose you do not understand.
- Record what you changed so you can reverse the procedure if necessary.
Clear the Browser Cache First
If the issue affects only your browser—for example, the page has old styling, an outdated JavaScript file, or a stale image—clear the browser’s cached files or test in a private window. A hard refresh may be enough: on many Windows and Linux browsers, press Ctrl + F5; on macOS, try Command + Shift + R. The exact shortcut varies by browser.
To clear cached files more thoroughly, open the browser’s settings, find its privacy or browsing-data controls, select cached images and files, and choose a time range. You usually do not need to delete saved passwords or cookies to refresh static files. If the application relies on a login session, clearing cookies may sign you out.
Ask another user to check the same page or use a different browser. If the page is stale everywhere, move on to the server-side checks rather than repeatedly clearing your browser cache.
Clear Application-Level Cache in JEE
Application-level caching is controlled by the application and the cache provider it uses. The cache might be implemented with Jakarta Caching (JCache), an in-memory map, a framework, or an external service such as Redis or Hazelcast. In these cases, clearing temporary server files will not necessarily remove the cached application data.
Look in the application’s configuration and logs for the cache provider and cache names. If the application offers an administrator page, management command, or documented cache-eviction endpoint, use that first. Many systems allow an administrator to clear one cache or one entry without restarting the whole service.
For a JCache-based application, cache entries are managed through the configured caching provider and its CacheManager. A developer can use the application’s existing cache-management code to clear a specific cache, for example by calling its clear operation. The exact code and permissions depend on the provider and application design; avoid adding an unprotected endpoint that lets any user empty a production cache.
If the cache is external, such as Redis, use the service’s approved administration tools and target the correct database, key pattern, or application namespace. Do not run a broad “flush all” command unless you have verified that the cache instance contains no data used by other applications. Some caches are disposable, while others may contain sessions or other information that users rely on.
Clear Temporary Files on Common Java Servers
Application servers often create temporary or generated files. Removing the appropriate files can help when stale compiled resources or deployment artifacts are suspected, but directory names and procedures vary by server version and configuration. Consult the documentation for your exact release before deleting anything.
-
Tomcat: Stop Tomcat before cleaning its temporary and generated work files. The
tempandworkdirectories are commonly used for temporary files and compiled JSP output. Their locations are usually inside the configured Tomcat base directory. Do not remove your application’s source, deployment archive, or persistent data. -
WildFly: Stop the relevant server instance before reviewing its temporary files. Standalone installations commonly use a
standalone/tmpdirectory; managed domain installations use instance-specific directories. Keep your configuration and deployment content intact. Do not delete a wholedatadirectory simply because it appears cache-related. -
Payara and GlassFish: Generated files are commonly stored under the domain directory, often in a
generateddirectory. Some versions and configurations also maintain other runtime or OSGi-related caches. Stop the domain and follow the instructions for your version rather than removing folders by guesswork. - WebLogic: Each server instance can have its own temporary and cache directories beneath its domain or server directory. Stop the affected managed server before cleaning approved temporary files. Preserve the domain configuration, deployment files, and persistent stores.
In general, the safe pattern is to stop the affected service, identify the documented temporary or generated directory, remove only the contents that the vendor says are safe to regenerate, and then restart the service. The server may take longer to start the next time because it needs to rebuild files. If the issue returns immediately, the underlying problem may be in the application, deployment, or configuration rather than the cache.
Refresh Maven or Gradle Build Output
If the problem occurs during development or testing, stale build output may be mistaken for a JEE server cache. For Maven, run mvn clean to remove the project’s generated build output, then build and redeploy the application. If a dependency appears corrupted, Maven can be instructed to update dependencies with mvn -U, though this does not indiscriminately erase every cached artifact.
For Gradle, run ./gradlew clean on macOS or Linux, or gradlew clean on Windows, and then rebuild. Use dependency refresh options only when you have a specific dependency-resolution problem; forcing every dependency to download again can take time and may not solve a server-side caching issue.
After rebuilding, verify that the deployment process copied the new artifact to the server. A clean build cannot help if the server is still running an older deployment or if the deployment pipeline targets a different instance.
Restart and Verify the Application
Once the correct cache has been cleared, restart only the service that needs it, unless your operating procedures call for a broader restart. Watch the startup logs for deployment errors, failed connections, or messages showing that the cache was recreated. Then test the application using a new browser session and, if possible, check the result from another user or server node.
Be aware that clearing a cache can temporarily increase load. The application may need to fetch records from a database or recreate compiled files, and many requests arriving at once can make that work more noticeable. For a busy production system, schedule the change appropriately and monitor response times, memory use, and error rates afterward.
Why Clearing the Cache May Not Fix the Problem
A cache is often blamed for symptoms caused by something else. If stale information comes back immediately, the application may be repopulating the cache from an outdated source. If users see different results on different servers, a cluster may have inconsistent deployments or cache invalidation. If a page is missing changes, the browser, reverse proxy, or content delivery network may be caching it independently of the JEE server.
Check application logs, deployment timestamps, cache expiration settings, and the source data. Confirm that every server node is running the expected application version. Also check whether a proxy or CDN has its own purge process. Avoid repeatedly deleting directories without identifying the source of the stale data; doing so can hide evidence and create unnecessary downtime.
Conclusion
To clear JEE cache safely, first determine whether the stale information is stored in the browser, application code, application server, build output, or a separate caching service. Clear only the relevant cache, follow the instructions for your server and version, and back up or preserve anything that may contain persistent data. If the problem continues after a targeted cleanup, investigate deployments, cache configuration, logs, and any proxies or clustered servers in the request path. There is no universal JEE cache-clear command, but identifying the cache layer makes the fix safer and much more reliable.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.