Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Static Resources entry
How-to guide

How to create a static resource

Upload a file as a static resource in Setup so your Visualforce, Aura, or Lightning Web Component code can reference it by name. The steps below create a single resource; package it in a ZIP first if you need to upload several related files together.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated Jun 16, 2026

Upload a file as a static resource in Setup so your Visualforce, Aura, or Lightning Web Component code can reference it by name. The steps below create a single resource; package it in a ZIP first if you need to upload several related files together.

  1. Open Static Resources in Setup

    From Setup, type Static Resources into Quick Find and select it, then click New to start a new resource.

  2. Name the resource

    Enter a Name that begins with a letter and uses only letters, numbers, and single underscores. Avoid spaces, trailing underscores, and consecutive underscores. Add a Description so future admins know what the file is for.

  3. Upload the file

    Click Browse and choose the file. It must be 5 MB or smaller. To bundle a library with its images and stylesheets, zip them together and upload the single archive.

  4. Set Cache Control

    Choose Public for files served on public Sites or Experience Cloud guest pages, or Private for resources that should reach only authenticated users in the org. Then click Save.

  5. Reference it from code

    In Visualforce use $Resource.YourName, in LWC import from @salesforce/resourceUrl/YourName, and in Aura use the $Resource value provider. For a file inside a ZIP, use URLFOR($Resource.YourName, 'path/file.ext').

Mandatory fields
Namerequired

The unique identifier code uses to reference the resource. Must begin with a letter and contain only alphanumeric characters and underscores, with no spaces or consecutive or trailing underscores.

Filerequired

The uploaded file itself, up to 5 MB. Can be a single asset or a ZIP or JAR archive that packages many files together.

Cache Controlrequired

Public shares one cached copy with all traffic for faster loads; Private keeps the cached copy in each user session and limits it to authenticated users.

Gotchas
  • The 5 MB per-resource cap is hard. Split or minify any library that exceeds it rather than trying to upload the full bundle.
  • Renaming a resource auto-updates Visualforce markup, but it does not fix references in Apex or LWC. Check that code by hand before renaming.
  • Choosing Private on a resource served from a public Site can stop it from caching as expected, which shows up as slow first loads for guests.

See the full Static Resources entry

Static Resources includes the definition, worked example, deep dive, related terms, and a quiz.