Loading

Static resources occasionally redirect to the login page

Udgivelsesdato: Jun 18, 2026
Beskrivelse

When a static resource has Cache Control set to Public, copying the View File URL from the resource's detail page and using it directly in an Experience Cloud (Community) page causes guest users to be intermittently redirected to the Salesforce login page. This is a known behavior and is not a bug.

Root Cause

The View File URL is served from the Salesforce application server tier (hosted on visual.force.com). When a guest user requests this URL, one of two things happens:

  1. If the resource is in the server-side cache: The request is served correctly.
  2. If the resource is not in the server-side cache: The request falls through to the application server, which only serves requests from visual.force.com for authenticated users. Since guest users are unauthenticated, they are redirected to the Salesforce login page.

This intermittent behavior is determined by whether the resource happens to be in cache at the time of the request.

Løsning

Why the View File URL Should Not Be Used Directly

The View File link in a static resource's detail page is intended for authenticated users accessing the resource from within Salesforce. It is not designed for direct embedding in Experience Cloud pages. Regardless of the Cache Control setting being "Public," this URL format is not safe for guest user access.
The URL formats generated by the View File button follow these patterns:

  • Org without namespace, My Domain not enabled: <REDACTED><instance>.visual.force.com/resource/<timestamp>/<static_resource_name>
  • Org without namespace, My Domain enabled: https://<my-domain>--c.<instance>.visual.force.com/resource/<timestamp>/<static_resource_name>
  • Org with namespace, My Domain not enabled: https://<namespace>.<instance>.visual.force.com/resource/<timestamp>/<namespace>__<static_resource_name>
  • Org with namespace, My Domain enabled: https://<my-domain>--<namespace>.<instance>.visual.force.com/resource/<timestamp>/<namespace>__<static_resource_name>

These URLs are accessible to users logged in via login.salesforce.com but are not intended for direct embedding.

Recommended Approach

Instead of copying the View File URL, reference static resources using the $Resource global merge field in your Visualforce page or Lightning Web Component (LWC). This ensures the URL is generated correctly for the context of the page — whether the user is an authenticated user or a guest.
For example, in Visualforce: {!$Resource.MyStaticResource}
This approach generates the correct cache-friendly URL regardless of the user's authentication state.

Yderligere ressourcer
Vidensartikelnummer

000383810

 
Indlæser
Salesforce Help | Article