Static resources added version number still hit the old cache, how should the cache header be written?

📅 October 9, 2026 👁️ 7

After adding version numbers to static resources, the browser still hits the old cache. The problem is usually not with the version number itself, but with the lack of coordination between the cache response header and the filename strategy. These are two separate issues:Freshness is determined by max-age, and whether the old copy can be used after expiration is determined by the validation requirements.If only a long freshness period is set without requiring a source validation, the browser may still reuse an outdated copy after expiration; and when the filename version and path remain unchanged, the old response may still be in the cache.

The cache of static resources directly determines the page loading speed, and also determines how many repeated requests the source site needs to handle under high concurrency, so this level of configuration is worth calculating separately by object, rather than using a uniform duration for the entire site.

Why is the browser still using the old file?

A point that is easy to misunderstand:max-ageIt refers to how fresh the response remains within a certain period after it is generated on the source site.The starting point is the generation time, not the receipt time.. Resources that have been cached or not accessed for a long time actually have a shorter available time than it appears on the surface. When it expires, the subsequent behavior depends on whether there are validation requirements.

The version number solves the issue of 'the same URL corresponds to different content.' When the file content changes, the address also changes, and the copy of the old address in the cache naturally no longer referenced; conversely, if the version number is only added to the query parameters while the path is reused, it may still encounter the old response.

Which field manages the freshness period and validation requirements

  • max-ageSet the freshness period, and it can be reused within the period;
  • must-revalidateThe requirement is to verify the source after expiration, if it cannot be verified, return 504 instead of continuing to send out outdated copies.
  • no-storeIt is completely not allowed to store, it is two different things from 'store but require verification'.
  • immutableIt indicates that the response will not be updated during the fresh period, thus avoiding unnecessary conditional requests, it is suitable for use with version numbers - the filename has determined the corresponding content version.

There is a common misconfiguration: setting for resources with version numbers at the same time.no-storeIt is equivalent to offsetting the benefits of versioning, and sourcing every time.

Why should shared cache and private cache be written separately.

s-maxageIt only takes effect on shared cache (CDN, reverse proxy) and will override.max-agewithExpires; Ignore it in private cache. So when the site is in front of a reverse proxy or CDN, only writemax-ageIt will make the shared cache follow the same duration, changing the style once will take a long time to refresh the entire network. The purpose of writing separately is to give the proxy layer a longer freshness period and the browser a shorter update freshness period.

Where should the version number be added to be effective

The version number added to the filename or path is more reliable than just adding query parameters: some caches and acceleration services handle addresses with parameters differently. At the same time, it must be confirmed that the publishing process really produces new files and not just pushes the old files again.

This is related to the deployment method of the site. For those deployed using Docker images, the static files are usually in the mounted volume, and when publishing, you need to confirm that the volume content is updated with the version; for those deployed using Baota panel or aaPanel, after the revision, you should also confirm whether the reverse proxy cache has been refreshed. For page URLs that depend on pseudo-static rules, do not affect the existing addresses when changing the file name strategy; when it comes to domain name or directory migration, use 301 redirect to point the old address to the new address so that the cache and search spiders can follow up.

The main page and static resources are separated

object Freshness orientation Complementary fields Reason
Static resources with version numbers Long immutableCompared with versioned filenames The address has been determined and the content does not need frequent verification
Static resources without version numbers Short Maintain verification requirements The address does not change when the content is modified, and long caching will hinder updates
Page HTML content Very short or not cached Verification on demand The content may be updated at any time, and readers will not see new articles if the cache is too long
Interface response class As the data varies Use shared cache cautiously Responses with user identity are not suitable for reuse in shared cache

The caching strategy of the page entity has the most direct impact: if the list page and article page are cached for a long time, readers may not see the new content they publish first. The refresh granularity at the proxy or CDN level also needs to be supplemented - if it is possible to refresh by path, do not use a full site clearance.

Common questions

Question: If a version number is added, do we still need must-revalidate?Answer: It can be optional, but don't write it as allowing outdated reuse. Versioned resources are more suitable for long freshness periods with immutable, while the page entity still needs to retain verification requirements.

How do you confirm which cache the browser is using?Look at the actual source and headers of the response, compare with the incognito window, it is more reliable than just looking at the local file time.

Do you need to change the version number every time you change the style?As long as the publishing process can automatically generate new filenames, there is no need to manually record them, the key point is to keep the content and address consistent.

Related articles

Should the backup take the uploaded images and static files together?

A backup of only the database will leave a very specific gap: after the restore, the article list is still there, but the images, attachments, and static resources in the main text all point to invalid addresses. The scope of a complete backup should cover both data and static files, and regular recovery drills should be conducted. The trash can only cover deleted documents and cannot replace backups; the location relationship of the backup files themselves should also be recorded with the site deployment directory and upload directory.

2026-10-09

When automatic updates are enabled, what is the difference between the default behavior of major and minor versions?

When automatic updates are enabled, there is a big difference in the default orientation between major and minor versions: An official operation manual of a mainstream program states that most sites default to enabling automatic updates, covering four categories: core, plugins, themes, and translation files. Since version 5.6, new installations have default automatic updates for both minor and major versions. For enterprise sites, a more stable compromise is to automatically update minor versions, manually evaluate major versions, and confirm the backup range before the upgrade to include both data and static files.

2026-10-09

How should the filing number be handled when changing servers or access providers?

How to handle the filing number when changing the server of the website, the judgment standard is whether the access provider has changed: When changing the access provider, the access filing should be handled at the new access provider, and the change of materials for the same subject should go through the change filing and require bureau review. This article clarifies two actions, the impact on access during the review period, and the most easily overlooked one when multiple sites share a domain name.

2026-10-09

The difference between panel one-click deployment and command line deployment, where are the differences in daily maintenance actions

Use the same program to deploy with one click on the panel or configure layer by layer with the command line, only once during the installation stage, the difference lies in the four daily actions of adding new sites, certificate renewal, log rotation and backup recovery. This article compares the workload of two paths for each action and explains why it is necessary to compare the environment first before comparing the data when migrating.

2026-10-09

Should compression be done in the program or in the Web server, and should static files be pre-compressed?

Dynamic compression consumes CPU each time a request is made and is limited by minimum length and type list; pre-compression shifts the cost to the publishing stage, sending the existing .gz file directly, but ensuring that the modification time of the original file matches that of the compressed file. The two layers are not substitutes: the content management program is responsible for generation, and the web server is responsible for choosing the sending method based on the client and type, with the help of caching and reverse proxy layers to achieve stable loading speed benefits.

2026-10-09

Certificates are valid for ninety days and automatically renewed, where should this be configured?

The default validity period of the HTTPS certificate is ninety days, and renewal should not wait until the browser alarms. Automatic renewal should be as a fixed scheduled task in the deployment process, after the certificate is issued and before the service is reloaded, and it is recommended to trigger once every sixty days. To confirm that it has been renewed, you need to check the actual expiration date of the online certificate, and also check the old address redirection and mixed content, and keep a backup before changing the certificate.

2026-10-10

Which parts need to be changed when replacing HTTP with HTTPS, including the internal addresses and redirections?

Changing from HTTP to HTTPS is not just about installing certificates. It also involves: the 301 redirect rules for old addresses, hardcoded absolute addresses within the site, the protocol in the sitemap and robots, pseudo-static and standard address configuration, as well as hard-coded links in navigation and single-page applications. The recommended sequence is to first handle certificates and redirects, then perform bulk replacements, and finally update the checklist files and review mixed content.

2026-10-10

After replacing the certificate, the page style is missing half, how to clear the http external links in the https page?

After replacing the certificate, the style is missing half, usually due to the residual http resources in the https page being blocked by the browser. The cleaning order is to first locate the residual references, then batch replace them with internal relative addresses or encrypted addresses according to the main text data, template, and configuration, and finally close the jump rules together.

2026-10-10