---
sourceType: best-practice
sourceTypeMatchedRule: best-practice
slug: MA/intro/best-practices/cache-data
title: Cache dữ liệu
---
Do các ứng dụng Zalo Mini App không hỗ trợ các API mặc định của trình duyệt như **LocalStorage** , **SessionStorage**, **Cookie** ... vui lòng sử dụng chức năng [Native Storage](/docs/MA/api/native-storage/setItem) để thay thế.

Mỗi ứng dụng Zalo Mini App sẽ được lưu tối đa 5MB dữ liệu và sẽ tự động xoá các dữ liệu cũ khi đầy.

### Sample code

```js
import { nativeStorage } from "zmp-sdk/apis";

const saveLocation = async (location) => {
    const locations = await loadLocations();
    
    locations.push(location);
    try {
        nativeStorage.setItem("recentLocations", locations);
    } catch (error) {
        console.log("Failed to save new recentLocation to storage. Details: ", error),
    }
    return locations;
}
```
