一些在前后端用来进行储存数据的地方或者方式

一些在前后端用来进行储存数据的地方或者方式

文件: 可以通过生成新文件的方式将新数据进行储存,这里要考虑到对文件的读写,容量,操作繁琐等等

数据库: 属于后端储存数据的地方,如果前端去拿数据的话需要发送HTTP请求

缓存: 也叫cache memory即缓存内存,就是说是内存的一部分。属于后端。google看一些文档解释如**cache memory** is a storage unit that stores copies of data from frequently used main**memory** locations so that the CPU can access that data faster,所以说一般这个是指备份,然后方便快读多写,但是会消耗CPU

内存:也叫virtual memory,内存的一部分。属于后端。google看一些文档解释如**virtual memory is a memory management technique that allows the user to execute programs larger than the actual main memory.**这是一门内存管理技术,允许用户执行比实际主要内存更大的程序。

Local StorageWeb storage API。属于前端。查mdn文档可以看到这个是Window.localStorage。看一下英文介绍

The read-only localStorage property allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions. localStorage is similar to sessionStorage, except that while data stored in localStorage has no expiration time, data stored in sessionStorage gets cleared when the page session ends — that is, when the page is closed.

It should be noted that data stored in either localStorage or sessionStorage is specific to the protocol of the page.

The keys and the values are always strings (note that, as with objects, integer keys will be automatically converted to strings).

首先这是储存在浏览器这边的,是前端部分。储存在本地储存的数据没有过期时间。即相对于页面的session会话结束,即页面关闭时,这个数据会被清除;本地储存不会清除。

Session StorageWeb storage API。属于前端。 查mdn文档,介绍

The sessionStorage property allows you to access a session Storage object for the current origin. sessionStorage is similar to localStorage; the only difference is while data stored in localStorage has no expiration time, data stored in sessionStorage gets cleared when the page session ends. A page session lasts for as long as the browser is open and survives over page reloads and restores.

Opening a page in a new tab or window causes a new session to be initiated with the value of the top-level browsing context, which differs from how session cookies work. Opening multiple tabs or Windows on the same URL creates sessionStorage for each tab or Window. Closing a tab or Window ends the session and the objects in sessionStorage are cleared as soon as the tab or Window is closed.

首先这是储存在浏览器这边的,是前端部分。只要浏览器是打开的,那么这个页面会话就会持续,并且存活下从页面重新加载reloads和恢复restores。在一个新标签或一个新的窗口打开一个页面,一个新的会话就会被初始化,伴随着最高级浏览环境的值,这个和会话cookies信息处理程序如何运作还是不同的。

Cookie: 参考mdn文档HTTP cookies。前后端都可以用。

An HTTP cookie (web cookie, browser cookie) is a small piece of data that a server sends to the user's web browser. The browser may store it and send it back with the next request to the same server. Typically, it's used to tell if two requests came from the same browser — keeping a user logged-in, for example. It remembers stateful information for the stateless HTTP protocol.

主要是服务器发送给客户端。

IndexedDB API: 参考mdn文档

IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data. While Web Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution. This is the main landing page for MDN's IndexedDB coverage — here we provide links to the full API reference and usage guides, browser support details, and some explanation of key concepts.

相对于Web Storage,这个主要是储存大量的结构化数据。

参考

Local Storage vs Session Storage vs Cookie

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章