Articles on: Database & Storage

Blob Storage: Persistent vs. temporary storage

Blob Storage: Persistent vs. Temporary Storage


Square Cloud's Blob Storage was designed to offer flexibility in file storage, ranging from temporary logs to critical application assets. The main difference between the storage modes lies in the expiration parameter and how the system handles file names.



1. Temporary Storage (Expire)


Temporary storage is ideal for files with a short lifecycle, such as on-demand reports, transitional backups, or cache files that don't need to take up space forever.


How It Works:

When uploading, you define the expire parameter in the URL. This value must be set in days, ranging from 1 day up to 365 days (1 year).


  • Automatic Hashing: A key feature of temporary mode is that the system generates a unique hash after the object name.
    • Example: If you upload imagem.png, the generated link might be something like imagem_a1b2c3.png.
  • Advantage: This prevents name conflicts if multiple users upload files with identical names simultaneously.



2. Persistent Storage (Permanent)


Persistent mode is the right choice for files that make up your application's structure, such as user profile pictures, logos, CSS, or documents that must be available indefinitely.


How It Works:

To make an object permanent, simply perform the upload without the expire parameter in the URL.


  • Overwrite: Unlike temporary mode, no hash is added here. If you upload a new file with the exact same name as an object that already exists in your Storage, the old file will be replaced by the latest version.
  • Advantage: Makes it easy to update static assets without needing to change the URL in your source code.



3. Quick Comparison


Feature

Temporary Storage

Persistent Storage

URL Parameter

Requires expire (1-365)

None (parameter missing)

Object Name

Receives a hash (e.g., name_hash.ext)

Original name (e.g., name.ext)

Lifecycle

Deleted after the set period

Remains active until manually deleted

Name Conflict

Creates a new file with a new hash

Overwrites the existing file



4. Which One to Choose?


  • Use Temporary for: Transaction receipts, debug logs, and files exported by users for a single download.
  • Use Persistent for: Interface images, lightweight SQLite databases, user uploads (like avatars), and configuration files.


Pro Tip: When using persistent storage to overwrite files, remember that browsers and CDNs may keep the old file cached for some time.

```

Updated on: 05/21/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!