1

I have a static resource with is a Javascript file of about 1mb. After successfully uploading the file, and clearing the cache of the page that uses the static resource, it's still using the old javascript file. Tried it 5+ times, still doesn't work.

Anybody know why it might be the case?

I'm workin in: https://c.na30.visual.force.com

3
  • 2
    Please post the Visualforce code that pulls in the JS file.
    – Rob
    Commented Jul 22, 2016 at 16:11
  • 1
    Are you using {!URLFOR(...)} or hard-coding your own URL?
    – sfdcfox
    Commented Jul 22, 2016 at 18:21
  • Well, miraculously, it started working that afternoon. No idea why. Just feel like I need to up date you on this. Thanks all!
    – MiaoMiao
    Commented Jul 26, 2016 at 21:20

1 Answer 1

0

The URL of a static resource automatically includes the timestamp when it was last updated providing you access it via $Resource (and similarly $Resource for Lightning) and this ensures that the static resource is re-cached at the client-side when it changes.

Use this mechanism in your logic.

Since $Resource doesn't work in communities, you can create the equivalent URL yourself via querying the static resource's LastModifiedDate:

    for (StaticResource sr : [
                select LastModifiedDate
                from StaticResource
                where Name = :name
                order by CreatedDate desc
                limit 1
                ]) {
        return '/resource/' + sr.LastModifiedDate.getTime() + '/' + name;
    }
enter code here

Another option is to have current date in Javascript like following

'/resource/'+Date.now()+'/staticResource'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .