Static asset

On this page 7

A static asset is a file that a web server or CDN delivers exactly as it is stored, with identical bytes for every visitor, without running application code to generate it. In web architecture, typical static assets are images, CSS files, JavaScript bundles, fonts, videos and downloadable documents, as opposed to dynamic responses that a backend builds per request.

The distinction matters because static assets can be cached aggressively, replicated globally and served at very low cost. Most of the bytes a modern page transfers are static assets, so the way they are named, compressed and cached largely determines loading performance.

What makes an asset static

An asset is static when its content does not depend on the request: not on the user, the session, cookies or the time of day. The server only needs to locate the file and stream it, which a web server or CDN edge does in microseconds, compared with milliseconds or more for a dynamic response that queries a database.

Static does not mean the file never changes. It means that each published version is immutable and the same for everyone until a new build replaces it. A JavaScript bundle rebuilt on every deployment is still a static asset, because between deployments it is served unchanged.

PropertyStatic assetDynamic response
Content sourceFile produced at build or upload timeGenerated by backend code per request
PersonalizationNone; identical for all usersCan depend on user, session or data
CacheabilityLong-lived shared cachingShort-lived, private or none
Server costMinimal file read or edge hitCPU, database and application time
Typical examplesImages, CSS, JavaScript, fontsAccount pages, search results, API data
Static assets compared with dynamic content

Types of static assets and their characteristics

Different asset types have different performance profiles. Text-based files compress well, while images and video are already compressed and gain more from choosing the right format and dimensions.

Asset typeCommon formatsMain optimization
StylesheetsCSSMinify, compress, inline critical rules
ScriptsJavaScript, WebAssemblyBundle splitting, minification, compression
ImagesAVIF, WebP, JPEG, PNG, SVGModern formats, responsive sizes
FontsWOFF2Subsetting, preloading key files
Video and audioMP4, WebM, adaptive streamingCorrect bitrate, streaming instead of download
DocumentsPDF, ZIPCompression, clear file naming
Common static asset types

Text assets are usually served with Brotli or gzip compression, which commonly shrinks minified CSS and JavaScript by 60 to 80 percent. Recompressing JPEG or AVIF files this way gains almost nothing, so servers typically skip it for those types.

Caching and versioning static assets

The most important practice for static assets is content-hashed file names combined with long-lived immutable caching. A build tool writes a hash of the file content into its name, for example app.3f9a2c.js, and the HTML references that exact name.

Because a changed file gets a new name, the old URL can be cached for a year or more without risk of serving stale code. The HTML document itself stays short-lived or revalidated, so a deployment becomes visible as soon as the new HTML is fetched.

ResourceCache-Control exampleReason
Hashed JS, CSS, fontspublic, max-age=31536000, immutableURL changes whenever content changes
Unhashed imagespublic, max-age=86400Moderate freshness without a new name
HTML documentsno-cacheAlways revalidated to pick up new references
Service worker scriptno-cacheUpdates must be detected promptly
Cache policy by resource role

Without hashing, teams fall back on query-string versions or short cache lifetimes, which either cause unnecessary downloads or leave users with outdated assets after a release.

Static assets in different architectures

Every architecture serves static assets, but the share of the site that is static varies widely. The trend toward headless and Jamstack architectures has turned entire pages into static assets.

ArchitectureWhat is staticTypical delivery
Traditional backendCSS, scripts, imagesSame server or a static directory
Full stack with CDNAll front-end filesCDN in front of the origin
JamstackPrebuilt HTML plus all assetsStatic hosting on a global CDN
Headless architectureFrontend build outputCDN, with content from an API
Role of static assets by architecture

Separating assets onto a CDN also reduces origin load, because the backend then handles only requests that genuinely need computation. This is a key reason why the frontend and backend are often deployed and scaled independently.

Common mistakes with static assets

Problems with static assets usually show up as slow pages, broken layouts after deployments or wasted bandwidth. Most of them are configuration issues rather than code bugs.

  • Deleting old hashed files too early: users with cached HTML request assets that no longer exist.
  • Serving oversized images: a 4,000-pixel photograph displayed in a 400-pixel slot wastes most of its bytes.
  • Missing compression for text files: uncompressed bundles can be several times larger in transfer.
  • Wrong content type headers: browsers may refuse to execute scripts or apply stylesheets.
  • Cookies on asset requests: sending cookies to an asset domain adds overhead and can weaken caching.

A reliable deployment keeps previous asset versions available for a grace period and uploads new assets before publishing the HTML that references them, so no visitor ever receives a page pointing to a missing file.

Put simply

A website is made of two kinds of material. Some parts are prepared fresh for each visitor, like a personal account page. Other parts are the same for everyone, like the logo, the fonts and the photos. Those identical parts are static assets.

Because static assets never change for a given version, they can be stored close to visitors and reused many times, like printed brochures stacked in every branch office instead of being printed on demand. That is what makes well-built sites fast.

In practice

A regional travel agency runs its website from a single server, and every page view also downloads the stylesheet, scripts and around 2 MB of photographs from that server. During a holiday campaign the server slows down under load, and pages take several seconds to load for visitors abroad.

The team configures the build to produce content-hashed file names, converts photographs to AVIF and WebP at several sizes and moves all static assets to a CDN with one-year immutable caching. The HTML pages stay on the origin with revalidation.

Repeat visitors now download almost nothing except the HTML, first-time visitors abroad receive assets from nearby edge locations, and the origin handles a small fraction of its former requests. Page weight drops substantially, and the next campaign runs without slowdowns.