How to clear cache and cookies using javascript

What is the Browser Cache?

The browser cache is used for storing website data like HTML, CSS, JavaScript, and images. Caching is a method of storing data that can be used later. Like other programs that you may have installed, browsers use caching to store website data on your computer instead of requesting the data from a web server to make web pages load faster.

What are Browser Cookies?

Browser cookies are different from the cache; Instead of making web pages load faster, they instead store text information like preferences and favorites.

What are Cookies Used For?

Cookies store authentication tokens that save your login info, keep the items that you have on your shopping cart or collecting other data from websites that you have visited and buttons that have been clicked for advertisers. Clearing your cookies can help you not get tracked by advertisers.

Clearing the Browser Cache and Cookies

How To Clear Cache and Cookies On Google Chrome

Step 1. Click on the menu button on the top right of your browser.

How to clear cache and cookies using javascript

Step 2. Click on the “Settings” button.

How to clear cache and cookies using javascript

Step 3. Click on “Privacy and security on the left side menu”.

How to clear cache and cookies using javascript

Step 4. Click on “Clear browsing data”.

How to clear cache and cookies using javascript

Step 5: Select “Cached images and files” to clear your browser cache.

How to clear cache and cookies using javascript

Step 6: Select “Cookies and other site data” to clear your browser cookies.

How to clear cache and cookies using javascript

Step 7: Click on “Clear data” button to clear your cache and/or cookies.

How To Clear Cache and Cookies On Mozilla Firefox

Step 1. Click on the menu button on the top right of your browser.

How to clear cache and cookies using javascript

Step 2. Click on the “Options” button.

How to clear cache and cookies using javascript

Step 3. Click on “Privacy & Security” on the left side menu.

How to clear cache and cookies using javascript

Step 4: Scroll down a bit until you find the “Cookies and Site Data” section, then click on “Clear Data…”.

How to clear cache and cookies using javascript

Step 5: Select “Cached Web Content” to clear your browser cache.

How to clear cache and cookies using javascript

Step 6: Select “Cookies and Site Data” to clear your browser cookies.

How to clear cache and cookies using javascript

Step 7: Click “Clear” to clear your cache and/or cookies. When removing your cookies, a prompt will pop up to confirm your decision on clearing your cookies.

How to clear cache and cookies using javascript

How To Clear Cache and Cookies On Opera

Step 1. Click on the menu button on the top right of your browser.

How to clear cache and cookies using javascript

Step 2. Scroll down to the “Privacy & Security” section and find and click on “Clear”.

How to clear cache and cookies using javascript

Step 3. Select “Cached images and files” to clear your browser cache.

How to clear cache and cookies using javascript

Step 4: Select “Cookies and other site data” to clear your browser cookies.

How to clear cache and cookies using javascript

Step 5: Click on “Clear data” button to clear your browser cache and/or cookies.

How To Clear Cache and Cookies On macOS Safari

Step 1. Click on “Safari” on the top menu bar.

How to clear cache and cookies using javascript

Step 2. Click on “Preferences”.

How to clear cache and cookies using javascript

Step 3. Click on “Privacy”, then click on “Manage Website Data…”.

How to clear cache and cookies using javascript

Step 4. Click on “Remove All”.

How to clear cache and cookies using javascript

Step 5. Click on “Remove Now” to clear your browser cache and cookies.

How to clear cache and cookies using javascript

How To Clear Cache and Cookies On Microsoft Edge

Step 1. Click on the menu button on the top right of your browser.

How to clear cache and cookies using javascript

Step 2. Click on the “Settings” button.

How to clear cache and cookies using javascript

Step 3. Click on the hamburger button to access the side menu.

How to clear cache and cookies using javascript

Step 4: Click on “Privacy and services”.

How to clear cache and cookies using javascript

Step 5: Scroll down to the “Clear browsing data” section and click on “Choose what to clear”.

How to clear cache and cookies using javascript

Step 6: Select “Cached images and files” to clear your browser cache.

How to clear cache and cookies using javascript

Step 7: Select “Cookies and other side data” to clear your browser cookies.

How to clear cache and cookies using javascript

Step 8: Click on “Clear now” button to clear your browser cache and/or cookies.

How To Clear Cache and Cookies On Microsoft Internet Explorer

Step 1. Click on the gear icon on the top right of your browser.

How to clear cache and cookies using javascript

Step 2. Click on “Internet options”.

How to clear cache and cookies using javascript

Step 3. On the “Browsing history” section, click on “Delete…”

How to clear cache and cookies using javascript

Step 4: Select “Temporary Internet files and website files” to clear your browser cache.

How to clear cache and cookies using javascript

Step 5: Select “Cookies and website data” to clear your browser cookies.

How to clear cache and cookies using javascript

Step 6: Click on the “Delete” button to clear your browser cache and/or cookies.

How To Clear Cache and Cookies On Chrome for Android

Step 1. Tap the menu button in the top right corner.

How to clear cache and cookies using javascript

Step 2. Tap on “Settings”.

How to clear cache and cookies using javascript

Step 3. Scroll down and tap on “Privacy”.

How to clear cache and cookies using javascript

Step 4: Tap on “Clear browsing data”.

How to clear cache and cookies using javascript

Step 5: Select “Cookies and site data” to clear your browser cookies.

How to clear cache and cookies using javascript

Step 6: Select “Cached images and files” to clear your browser cache.

How to clear cache and cookies using javascript

Step 7: Tap on “Clear data” button to clear your browser cache and/or cookies.

How To Clear Cache and Cookies On Safari for iOS

Step 1. Go to Settings.

How to clear cache and cookies using javascript

Step 2. Scroll down until you see the Safari tab.

How to clear cache and cookies using javascript

Step 3. Scroll a bit to the “Clear History and Website Data” button.

How to clear cache and cookies using javascript

Step 4. Click on “Clear History and Data” to clear your browser cache and cookies.

How to clear cache and cookies using javascript

Plugins and Tools

While Liquid Web does not officially endorse any specific plugins or tools regarding this task, we have found the following highly rated third-party plugins and tools exceedingly helpful in keeping your browser clean.

This is a 5 star Google Chrome and Mozilla Firefox plugin that lets you clear all your cache and cookies or just the tab that you’re on with a single click.

Super History & Cache Cleaner

This is a 4.5 star Google Chrome store rated extension used by over 70,000 users. It is user-friendly and can choose a time when to clear your cookies or cache makes it ideal for any type of Chrome user.

Cookie AutoDelete has 4.6 stars on the Mozilla Firefox add-ons store used by over 160,000 users. Despite its name, it is used for clearing recent browsing history, cookies, and cache with a schedule also built into it.

Clear Browsing Data

Clear Browsing Data is a 4.1 store Opera add-on. It is not just for clearing browsing data but also cookies and cache.

Super History & Cache Cleaner

Super History & Cache Cleaner is a 5-star Microsoft Edge rated add-on for clearing browsing and cookie data. It’s quick “Close All Windows and Clear All Cache” button makes it a lightweight choice for the user experience.

Cookie - AutoDelete is an open-source option for Google Chrome and Mozilla Firefox, and Microsoft Edge Chromium licensed under the MIT license. It is used for clearing browser cookies automatically from closed tabs but does not remove browsing data.

Conclusion

How do you clear all cookies using JS?

As this attribute is configurable*, it is possible to delete all the cookies by setting the “expiry” to any value that has already passed. The cookie property of the current document is used to modify the attributes of the cookies buy using HTML DOM cookie Property.

Can JavaScript delete cookies?

JavaScript can create, read, and delete cookies with the document.cookie property.

How do I programmatically delete cookies?

“how to clear cookies programmatically” Code Answer.
function deleteAllCookies() {.
var cookies = document. cookie. ... .
for (var i = 0; i < cookies. length; i++) {.
var cookie = cookies[i];.
var eqPos = cookie. indexOf("=");.
var name = eqPos > -1 ? cookie. ... .
document. cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";.

Can we manipulate cookies using JavaScript?

JavaScript can also manipulate cookies using the cookie property of the Document object. JavaScript can read, create, modify, and delete the cookies that apply to the current web page.