function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jingli Hu 3Jingli Hu 3 

best practices for static resources.

Hi,

Our company have run a security scan tool and found most of our static resources are public. and asking us whether we can switch them to private.  as understanding setting the static resource as public will cache it for all users, and sett it as private will only cache it for current user session. I don't think we should swtich all to private. I am trying to find best practics for using static resources. I found the link below, but it shows blank page. any recommendation from salesforce on how we should use static resources?

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_additional_page.htm
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Jingli,

I was able to access the above link and below is the information present in the link:

Best Practices for Static Resources
Displaying the Content of a Static Resource with the action Attribute on <apex:page>

You can use the action attribute on a <apex:page> component to redirect from a Visualforce page to a static resource. This functionality allows you to add rich, custom help to your Visualforce pages. For example, to redirect a user to a PDF:
1.Upload the PDF as a static resource named customhelp.
2.Create the following page:

<apex:page sidebar="false" showHeader="false" standardStylesheets="false" 
      action="{!URLFOR($Resource.customhelp)}">
</apex:page>

Notice that the static resource reference is wrapped in a URLFOR function. Without that, the page does not redirect properly.

This redirect is not limited to PDF files. You can also redirect a page to the content of any static resource. For example, you can create a static resource that includes an entire help system composed of many HTML files mixed with JavaScript, images, and other multimedia files. As long as there is a single entry point, the redirect works. For example:

1.Create a zip file that includes your help content.
2.Upload the zip file as a static resource named customhelpsystem.
3.Create the following page:
<apex:page sidebar="false" showHeader="false" standardStylesheets="false" 
      action="{!URLFOR($Resource.customhelpsystem, 'index.htm')}">
</apex:page>

When a user visits the page, the index.htm file in the static resource displays.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Jingli Hu 3Jingli Hu 3
Thanks ANUTEJ, I would like to know what’s the recommendations for setting up public or private for static resource. Thanks