How to clear browser cache in angularJs
This article mainly introduces the method of clearing the browser cache in angularJs. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor and take a look
Caching
A cache is a component that can store data transparently so that it can serve requests faster in the future. . Obtaining resources repeatedly may cause data duplication and consume time. Therefore, caching is suitable for some data with little variability. The more requests the cache can serve, the more the overall system performance can be improved.
Browser cache, sometimes we need it, because it can improve website performance and browser speed, and improve website performance. But sometimes we have to clear the cache, because the cache may cause problems and some erroneous data may appear. For example, stock websites are updated in real time. Such websites do not need to be cached. Some websites are rarely updated, so it is better to have cache.
The following is the traditional method of clearing the browser
meta method
//不缓存 <META HTTP-EQUIV="pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> <META HTTP-EQUIV="expires" CONTENT="0">
Clear the temporary cache of the form
<body onLoad="javascript:document.yourFormName.reset()">
ajax clear cache
$.ajax({ url:'www.haorooms.com', dataType:'json', data:{}, cache:false, ifModified :true , success:function(response){ //操作 } async:false });
Use random numbers. Random numbers are also a very good way to avoid caching!
Add "?ran=" Math.random(); //Of course the parameter ran here can be chosen arbitrarily
Use random time, the same as random number.
Add "?timestamp=" new Date().getTime(); after the URL parameters
Use php backend to clean up
Add header("Cache-Control: no-cache, must-revalidate"); and so on on the server side (such as in php)
The following is an introduction to the method of clearing the browser in the angularJs project. Of course, the above traditional method is It is also applicable, but for angularJs, the following items need to be added:
1. Clear the template cache
.run(function($rootScope, $templateCache) { $rootScope.$on('$routeChangeStart', function(event, next, current) { if (typeof(current) !== 'undefined'){ $templateCache.remove(current.templateUrl); } }); });
2. Add random parameters to html
.state("content", { url: "/", views:{ "bodyInfo":{templateUrl: 'tpls/bodyInfo.html?'+ +new Date(), controller:'bodyInfoCtrl'}, "header":{templateUrl: 'tpls/header.html?'+ +new Date(), controller:'headerCtrl' }, "footer":{templateUrl: 'tpls/footer.html?'+ +new Date(), controller:'footerCtrl' } } })
<link rel="stylesheet" href="stylesheets/main.css?version=1.0.3" rel="external nofollow" >
3. Clear the route cache
.config(['$stateProvider', '$urlRouterProvider','$locationProvider','$httpProvider',function($stateProvider, $urlRouterProvider,$locationProvider,$httpProvider) { // $urlRouterProvider.when("", "/home"); $urlRouterProvider.otherwise('/'); if (!$httpProvider.defaults.headers.get) { $httpProvider.defaults.headers.get = {}; } $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest'; $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache'; $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
Okay...that’s all
If there are other methods, please give me some advice !
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to implement circular references between components in Vue.js
There are examples of asynchronous components in Vue
How to solve the maximum call stack error in nodejs
How to implement the blog management platform in Vue SpringBoot
The above is the detailed content of How to clear browser cache in angularJs. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The Windows operating system uses a cache to store DNS entries. DNS (Domain Name System) is the core technology of the Internet used for communication. Specifically the IP address used to look up domain names. When a user types a domain name into their browser, one of the first tasks performed when a site loads is to find its IP address. This process requires access to a DNS server. Typically, the Internet Service Provider's DNS servers are used automatically, but administrators may switch to other DNS servers because they may be faster or provide better privacy. Switching DNS providers may also help bypass Internet censorship if DNS is used to block access to certain sites. Windows uses DNS solution

What is cache? A cache (pronounced ka·shay) is a specialized, high-speed hardware or software component used to store frequently requested data and instructions, which in turn can be used to load websites, applications, services, and other aspects of the system faster part. Caching makes the most frequently accessed data readily available. Cache files are not the same as cache memory. Cache files refer to frequently needed files such as PNGs, icons, logos, shaders, etc., which may be required by multiple programs. These files are stored in your physical drive space and are usually hidden. Cache memory, on the other hand, is a type of memory that is faster than main memory and/or RAM. It greatly reduces data access time since it is closer to the CPU and faster compared to RAM

For those of you who are not familiar with the term, clearing cache simply means clearing it, and this article will show you how to do it easily in Windows 11. If you're still wondering what cache files are, you should know that it's not as technical as it sounds. Thinking about computers, caches are non-permanent files (or files) that may be needed again in the future. Therefore, the cache remains hidden until that time arrives, thus protecting the content. Caching files is important, but they also take up valuable space. This can be a problem if your SSD has limited capacity. However, there is some good news. Therefore, in most cases, cache files can be safely wiped to clear disk space. Important to Clear Windows 11 Cache

Safari's cache makes browsing faster, but it can be buggy, slow down your Mac, iPhone, or iPad, and it can also take up a lot of storage space. Here's how and when to clear it. Like all web browsers, Safari stores data on your Mac, iPhone, and iPad with the express purpose of speeding up your online life. You might have the kind of internet speed you take for granted at Apple Park, but even then, it's best to use that speed where you need it. So when you revisit a website, Safari will try its best to allow you to download only the content that has changed. Even if a news website is updated all day long, the basic layout, furniture of the page

Javascript is a very unique language. It is unique in terms of the organization of the code, the programming paradigm of the code, and the object-oriented theory. The issue of whether Javascript is an object-oriented language that has been debated for a long time has obviously been There is an answer. However, even though Javascript has been dominant for twenty years, if you want to understand popular frameworks such as jQuery, Angularjs, and even React, just watch the "Black Horse Cloud Classroom JavaScript Advanced Framework Design Video Tutorial".

Methods to clear browser cache: 1. Manually clean; 2. Use browser settings to clean; 3. Use third-party tools to clean; 4. Clean regularly; 5. Manually delete cache files; 6. Use browser extensions to clean; 7 , disable browser cache; 8. Manually delete cookies and cookie-related files. Detailed introduction: 1. Manual cleaning, open the browser, press Ctrl+Shift+Delete keys on the keyboard, in the pop-up dialog box, select the "Clear browsing data" option, and select the time range to be cleared, etc.

How to clear cache on iPhone and iPad in Safari and other apps Open Safari Open Settings Swipe down and tap Safari Swipe down again and tap Clear History and Website Data Tap again to confirm Alternatively, if you want to clear an individual Without clearing the entire Safari cache, select Advanced > Website Data > Edit at the very bottom of Safari settings (or swipe from right to left to delete individual items). Keep in mind that website data deleted from your iPhone or iPad will be deleted from other Apple devices you are signed into the same iCloud account if they are synced with Safari. Clear i

In today's information age, websites have become an important tool for people to obtain information and communicate. A responsive website can adapt to various devices and provide users with a high-quality experience, which has become a hot spot in modern website development. This article will introduce how to use PHP and AngularJS to build a responsive website to provide a high-quality user experience. Introduction to PHP PHP is an open source server-side programming language ideal for web development. PHP has many advantages, such as easy to learn, cross-platform, rich tool library, development efficiency
