什么是浏览器缓存?如何在所有主要浏览器中清除浏览器缓存?

发布时间:   来源:CSDN  

When fixing common WordPress errors, one common piece of advice that you would often receive is to “clear your browser cache”.

修复常见的WordPress错误时 ,您经常会收到的一条常见建议是“清除浏览器缓存”。


【资料图】

Since you don’t need to clear browser cache for day to day internet use, most non-techy users are not familiar with the process.

由于您不需要为日常使用的互联网清除浏览器缓存,因此大多数非技术人员都不熟悉该过程。

In this beginner’s guide, we will show you how to quickly clear your browser cache in all major browsers, step by step. We will also explain what is browser cache and how browser caching works.

在此初学者指南中,我们将逐步向您展示如何在所有主要浏览器中快速清除浏览器缓存。 我们还将解释什么是浏览器缓存以及浏览器缓存的工作方式。

什么是浏览器缓存? (What is Browser Cache?)

Browser cache is a technology used by most popular web browsers to save visited website’s data on a user’s computer. This allows the browser to quickly display a webpage on your next visit.

浏览器缓存是最流行的Web浏览器使用的一种技术,用于将访问过的网站的数据保存在用户的计算机上。 这使浏览器可以在您下次访问时快速显示网页。

The logic behind it is that downloading static files from a WordPress hosting server located far away will take more time than reusing the resources from the user’s computer. This reduces the overall page load time and makes your online experience faster.

其背后的逻辑是,与重用用户计算机中的资源相比,从远处的WordPress托管服务器下载静态文件将花费更多时间。 这样可以减少整体页面加载时间,并使您的在线体验更快。

Typically browsers will not cache complete web pages unless the web developers specifically tell them to do it (via code). Instead browsers focus on static content like stylesheets, images, and JavaScript.

通常,浏览器不会缓存完整的网页,除非Web开发人员明确指示他们(通过代码)这样做。 相反,浏览器专注于样式表,图像和JavaScript等静态内容。

Why browsers cache static content?

为什么浏览器缓存静态内容?

Browser cache static content because it does not change as often as dynamic content.

浏览器缓存静态内容,因为它不会像动态内容那样频繁地更改。

For example, if you visit a WordPress website then the content of your posts and pages is more likely to change than your WordPress theme.

例如,如果您访问WordPress网站,则与WordPress主题相比,帖子和页面的内容更有可能发生变化。

A typical website template includes several stylesheets, JavaScript files, and images. These files remain the same on each page, so downloading a fresh copy on every page load is simply inefficient.

一个典型的网站模板包括几个样式表,JavaScript文件和图像。 这些文件在每个页面上都保持不变,因此在每次加载页面时下载新副本的效率很低。

This is why browsers keep a copy of these static files in a temporary storage folder on your computer, so they use that copy on your next website visit.

这就是为什么浏览器将这些静态文件的副本保留在您计算机上的临时存储文件夹中,以便它们在您下次访问网站时使用该副本。

If you are using a WordPress caching plugin, then it may add guidelines for browsers to cache your static content along with expiration instructions for each resource type.

如果您使用的是WordPress缓存插件 ,则它可能会为浏览器添加一些准则,以供浏览器缓存您的静态内容以及每种资源类型的过期说明。

This improves user experience and makes the internet faster for everyone.

这样可以改善用户体验,并使所有人的互联网速度更快。

Why and when you need to clear browser cache?

为什么以及何时需要清除浏览器缓存?

Most popular browsers are smart about deciding which content to store in cache.

大多数流行的浏览器都很聪明地决定要存储在缓存中的内容。

However, sometimes they are unable to figure out that the website you are viewing has changed. In that case, browsers will still load the cached version of files from local storage.

但是,有时他们无法确定您正在查看的网站已更改。 在这种情况下,浏览器仍将从本地存储加载文件的缓存版本。

This leads you to see an outdated version of a web page, and the website may not work as intended. If you have made some changes to your website, then you may not see them appear on the live site.

这会导致您看到网页的过时版本,并且该网站可能无法正常工作。 如果您对网站进行了某些更改,则可能看不到它们出现在实时网站上。

This is when you need to force reload that page in other words clear your browser cache.

在这种情况下,您需要强制重新加载该页面,换句话说,清除浏览器缓存。

Force browser to refresh / reload a page (Shortcut)强制浏览器刷新/重新加载页面(快捷方式) Clearing browser cache in Google Chrome在Google Chrome中清除浏览器缓存 Clearing browser cache in Firefox在Firefox中清除浏览器缓存 Clearing browser cache in Internet Explorer在Internet Explorer中清除浏览器缓存 Clearing browser cache in Edge在Edge中清除浏览器缓存 Clearing browser cache in Safari在Safari中清除浏览器缓存 Clearing browser cache in Opera在Opera中清除浏览器缓存 What to do when clearing browser cache doesn’t fix the problem?清除浏览器缓存无法解决问题时该怎么办?

强制浏览器硬刷新/重新加载页面 (Forcing Browsers to Hard Refresh / Reload a Page)

Before you clear your browser cache, you may want to try this step because it’s much faster and easier (this is what the Pros do).

在清除浏览器缓存之前,您可能需要尝试此步骤,因为它更快,更轻松(这是专业人士所做的)。

Basically, when you click on the refresh button in your browser, it will load static content from browser cache. However by using a keyboard shortcut, you can force the browser to bypass cache and download a fresh version of the web page.

基本上,当您单击浏览器中的刷新按钮时,它将从浏览器缓存中加载静态内容。 但是,通过使用键盘快捷键,您可以强制浏览器绕过缓存并下载网页的新版本。

Simply press the following keys to force a hard refresh in your web browser.

只需按以下键,即可在Web浏览器中强制硬刷新。

Google Chrome on Mac: Command + Shift + RMac上的Google Chrome:Command + Shift + R Google Chrome on Windows & Linux: CTRL + F5Windows和Linux上的Google Chrome浏览器:CTRL + F5 Firefox on Mac: Command + Shift + RMac上的Firefox:Command + Shift + R Firefox on Windows & Linux: CTRL + F5Windows和Linux上的Firefox:CTRL + F5 Safari: Command + Option + RSafari:Command + Option + R Opera on Mac: Command + Alt + RMac上的Opera:Command + Alt + R Opera on Windows: Shift + F5Windows上的Opera:Shift + F5

Normally forcing a hard refresh will solve your problem. However if it dose not, then you need to clear your browser cache to make sure that you are seeing the live version of a web page.

通常,强制硬刷新将解决您的问题。 但是,如果不这样做,那么您需要清除浏览器缓存以确保您看到的是实时网页。

在Google Chrome中清除浏览器缓存 (Clearing Browser Cache in Google Chrome)

Google Chrome is the most popular browser in the world right now. Here is how to clean the browser cache in Google Chrome.

Google Chrome浏览器是目前世界上最受欢迎的浏览器。 以下是在Google Chrome浏览器中清除浏览器缓存的方法。

Simply launch the Google Chrome web browser on your computer and then click on the three-dot menu in the top right corner. From the menu, you need to go to More Tools » Clear Browsing Data.

只需在计算机上启动Google Chrome浏览器,然后单击右上角的三点菜单即可。 从菜单中,您需要转到更多工具»清除浏览数据。

This will launch the Chrome Settings page with ‘Clear Browsing Data’ popup displayed on the screen. You need to switch to the Basic settings and then select ‘All time’ next to time-range option.

这将启动Chrome设置页面,并在屏幕上显示“清除浏览数据”弹出窗口。 您需要切换到基本设置,然后在时间范围选项旁边选择“所有时间”。

Below that, you need to check the box next to the ‘Cached images and files’ option.

在此之下,您需要选中“缓存的图像和文件”选项旁边的框。

You can also select ‘Clear cookies and other site data’ option. It will delete all cookies stored in your browser storage. Doing so will also log you out from all websites and end other sessions.

您还可以选择“清除Cookie和其他站点数据”选项。 它将删除浏览器存储中存储的所有cookie。 这样做还将使您退出所有网站并结束其他会话。

Next, click on the ‘Clear data’ button and Google Chrome will clear the browser cache.

接下来,点击“清除数据”按钮,然后Google Chrome浏览器将清除浏览器缓存。

在Firefox中清除浏览器缓存 (Clearing Browser cache in Firefox)

If you are using Mozilla Firefox, then this is how you can clear your browser cache.

如果您使用的是Mozilla Firefox,那么这就是清除浏览器缓存的方法。

First, you need to launch the Firefox web browser on your computer. After that, you need to click on the hamburger menu on the top-right corner of the screen and select the ‘Preferences’ option.

首先,您需要在计算机上启动Firefox Web浏览器。 之后,您需要点击屏幕右上角的汉堡菜单,然后选择“偏好设置”选项。

This will bring up the Firefox settings page. From here, you need to switch to the ‘Privacy and Security’ tab, and then click on the ‘Clear Data’ button.

这将打开Firefox设置页面。 从这里,您需要切换到“隐私和安全性”选项卡,然后单击“清除数据”按钮。

Firefox will now ask what data do you want to clear. You need to select ‘Cached Web Content’ and click on the clear button.

Firefox现在将询问您要清除哪些数据。 您需要选择“缓存的Web内容”,然后单击清除按钮。

Firefox will now delete cached web content from your browser storage.

Firefox现在将从您的浏览器存储中删除缓存的Web内容。

在Internet Explorer中清除浏览器缓存 (Clearing Browser Cache in Internet Explorer)

Internet Explorer was the default web browser on Windows computers until it was replaced by the new Microsoft Edge browser.

Internet Explorer是Windows计算机上的默认Web浏览器,直到被新的Microsoft Edge浏览器取代。

However, many users still use it. If you are one of those users, then this is how you’ll clear browser cache in Internet Explorer.

但是,许多用户仍在使用它。 如果您是这些用户之一,那么这就是在Internet Explorer中清除浏览器缓存的方法。

First, you need to launch the Internet Explorer on your computer. After, that you need to click on the gear icon at the top right corner and then select Safety » Delete browsing history….

首先,您需要在计算机上启动Internet Explorer。 之后,您需要单击右上角的齿轮图标,然后选择安全»删除浏览历史记录…。

Next, you need to uncheck the option to ‘Preserve Favorites website data’, check ‘Temporary internet files’, and optionally check the ‘Cookies’ option.

接下来,您需要取消选中“保留收藏夹网站数据”的选项,选中“临时Internet文件”,并选择选中“ Cookies”选项。

Click on the Delete button to continue, and Internet Explorer will empty your browser cache.

单击删除按钮继续,然后Internet Explorer将清空浏览器缓存。

在Edge中清除浏览器缓存 (Clearing Browser cache in Edge)

Edge is the default browser on Windows 10 computers. Here is how you will clear browser cache in Microsoft Edge.

Edge是Windows 10计算机上的默认浏览器。 这是清除Microsoft Edge中浏览器缓存的方法。

First, you need to open the Edge browser on your computer. After that, you need to click on the three-dot menu at the top-right corner of the screen and select ‘Settings’ option.

首先,您需要在计算机上打开Edge浏览器。 之后,您需要单击屏幕右上角的三点菜单,然后选择“设置”选项。

Next, you need to click on the ‘Choose what to clear’ button under the ‘Clear browsing data’ section.

接下来,您需要点击“清除浏览数据”部分下的“选择要清除的内容”按钮。

This will bring up the ‘Clear browsing data’ panel. From here, you need to select ‘Cached data and files’ and ‘Cookies and website data’ options.

这将弹出“清除浏览数据”面板。 在这里,您需要选择“缓存的数据和文件”以及“ Cookie和网站数据”选项。

Click on the ‘Clear’ button and Microsoft Edge will now clear browser cache.

单击“清除”按钮,Microsoft Edge现在将清除浏览器缓存。

在Safari中清除浏览器缓存 (Clearing Browser Cache in Safari)

Safari is the default browser on the Mac operating system. Here is how to clear browser cache in Safari.

Safari是Mac操作系统上的默认浏览器。 这是在Safari中清除浏览器缓存的方法。

First, you need to open the Safari web browser on your computer. After that. click on the History » Clear History…option from the top menu.

首先,您需要在计算机上打开Safari Web浏览器。 之后。 单击顶部菜单中的“ 历史记录»清除历史记录...”选项。

Safari will now ask you to select a time range. Select ‘All history’ from the ‘Clear’ dropdown menu and then click on the ‘Clear History’ button.

Safari现在将要求您选择一个时间范围。 从“清除”下拉菜单中选择“所有历史记录”,然后单击“清除历史记录”按钮。

Safari will now delete all temporary data including cache, cookies, and all temporary website data.

Safari现在将删除所有临时数据,包括缓存,Cookie和所有临时网站数据。

If you want to empty the Safari cache without deleting cookies and other data, then you will need to enable the ‘Developer’ menu.

如果要清空Safari缓存而不删除Cookie和其他数据,则需要启用“开发人员”菜单。

Simply click on the Safari » Preferencesfrom the top menu. This will bring up the settings dialog box where you need to switch to the ‘Advanced’ tab.

只需从顶部菜单中单击Safari»首选项。 这将弹出设置对话框,您需要在其中切换到“高级”选项卡。

This will add the ‘Develop’ menu in your web browser’s top bar. Next, you need to click on the Develop menu and select ‘Empty Caches’ option.

这将在网络浏览器的顶部栏中添加“开发”菜单。 接下来,您需要单击“开发”菜单,然后选择“空缓存”选项。

Safari will now only empty the browser cache without deleting cookies and other temporary data.

Safari现在只会清空浏览器缓存,而不会删除Cookie和其他临时数据。

在Opera中清除浏览器缓存 (Clearing Browser Cache in Opera)

If you are using Opera web browser, then here is how to clear your browser cache in Opera.

如果您使用的是Opera网络浏览器,那么以下是在Opera中清除浏览器缓存的方法。

Fist, open the Opera web browser on your computer. After that, click on the menu icon on the top right corner of the screen and then click on the ‘Clear browsing data’ button.

拳头,打开计算机上的Opera Web浏览器。 之后,点击屏幕右上角的菜单图标,然后点击“清除浏览数据”按钮。

This will bring up a popup on the screen. From here, first you need to select ‘All time’ next to the time range dropdown menu. After that, check the box next to the ‘Cached images and files’ option.

这将在屏幕上弹出一个弹出窗口。 首先,您需要在时间范围下拉菜单旁边选择“所有时间”。 之后,选中“缓存的图像和文件”选项旁边的框。

You can now click on the ‘Clear data’ button, and Opera will empty your browser cache.

现在,您可以单击“清除数据”按钮,Opera将清空浏览器缓存。

清除浏览器缓存不起作用时该怎么办? (What to Do When Clearing Browser Cache Doesn’t Work?)

It depends on what you are trying to do at the moment. Let’s take a look at some common scenarios.

这取决于您当前要执行的操作。 让我们看一些常见的场景。

1. Can’t see changes you made to your website appear on the live site

1.无法看到您对网站所做的更改显示在实时网站上

The most common culprit for this usually a WordPress caching plugin. Normally, if you are logged in to WordPress, then your caching plugin would show you a non-cached version of your website.

最常见的罪魁祸首通常是WordPress缓存插件。 通常,如果您登录WordPress ,则您的缓存插件将为您显示网站的非缓存版本。

However, due to a plugin misconfiguration, you may end up seeing a cached version of your website.

但是,由于插件配置错误,您最终可能会看到网站的缓存版本。

You’ll need to empty WordPress cache to see the live version. We have a detailed guide on how to clear cache in WordPress with step by step instructions.

您需要清空WordPress缓存才能看到实时版本。 我们有详细的指南,指导您如何逐步清除WordPress中的缓存 。

2. I cannot log in to my WordPress website

2.我无法登录我的WordPress网站

If you are unable to log in to your WordPress website and the login page keeps refreshing, then most likely it is a WordPress settings issue.

如果您无法登录WordPress网站并且登录页面不断刷新,则很可能是WordPress设置问题。

See our detailed guide on how to fix WordPress login page refresh and redirecting issue.

请参阅有关如何解决WordPress登录页面刷新和重定向问题的详细指南。

3. A third party website is not updating

3.第三方网站未更新

If you are seeing an outdated version of a third-party website while other users can see the changes, then this could happen due to a lot of reasons.

如果您看到的是第三方网站的过时版本,而其他用户可以看到更改,则可能由于多种原因而发生。

For example, the website may be temporarily down, and their CDN server is showing a cached copy of the website. It is also possible that their website firewall is not working properly, and it’s serving the cached versions to specific geographic locations.

例如,网站可能暂时关闭,其CDN服务器正在显示网站的缓存副本。 他们的网站防火墙也可能无法正常工作,并且正在将缓存的版本提供给特定的地理位置。

In that case, you can try using a VPN service. This will allow you to change your IP address and visit the website from a different geographic location.

在这种情况下,您可以尝试使用VPN服务 。 这将允许您更改IP地址并从其他地理位置访问网站。

This will help you further troubleshoot and get to the bottom of the issue.

这将帮助您进行进一步的故障排除并深入了解问题的根源。

We hope this article helped you learn how to quickly clear your browser cache in all top browsers. You may also want to see our WordPress troubleshooting tips and the complete WordPress security guide to keep your website secure.

我们希望本文能帮助您学习如何在所有顶级浏览器中快速清除浏览器缓存。 您可能还想查看我们的WordPress故障排除提示和完整的WordPress安全指南,以确保您的网站安全。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在Twitter和Facebook上找到我们。

相关文章Related

返回栏目>>