+ Start a Discussion
JasonGablerJasonGabler 

How to display a static resource in a public Sites Visualforce page?

When I tried {!$Resource.resources_name} in my Site's VF pages, I see the "/resource/..." URL, which does not work for the host address of my Site.  All I see, for example for images, are broken image icons.  If I take the relative URL supplied by the {!$Resource...} and put it on the hostname of my Salesforce instance when logged into Salesforce proper, it works fine. I know that all permissions are properly set for the Site guest user profile (unless I missed a specific one for static resources somewhere).  I did set the caching for each resource to public.   If I am logged into Salesforce proper and looking at my Site, that s the only way I can see the static resources. Of course, my future customers will not be able to see them.

 

Any suggestions?

IspitaIspita

Hi,

 

For public pages, Force.com uses a global content delivery network of cache servers that hold copies of your static files. If a URL request comes in for a file that is already in the cache, it serves up the cached version instead of retrieving it from the Force.com platform. This leads to a faster response time. Keep in mind that for this to work properly, you should set the Cache Control setting on the resource to Public.

 

You have to set cache control to Public

 

For more clarity refer to the link below:-

 

http://wiki.developerforce.com/page/Delivering_Static_Resources_with_Visualforce

 

 

Hope this helps..

JasonGablerJasonGabler

Funny you should ask, I just went to edit the original post that I did infact set the cache to public... and still I can only see then on the Site if I am logged into Salesforce proper.  Thanks for the link, I've actually already reference that.  So... still not working.  Thanks though.

 

 

edit:  By the way, I can see images imbeded in rich text fields just fine.

ssousanssousan

Did you figure this out?

I need to do the same thing,

 

Thanks

Eric FortenberryEric Fortenberry
I am having the same issue.  Did you figure it out?
Bernard CarpioBernard Carpio
Hi,

I did what Ispita's advised and it works perfectly.

Thanks!