redconservatory
redconservatory

Reputation: 21934

Force a browser refresh, but only for Safari on OS X?

Is there any way to force a browser to refresh or empty it's cache, but only if that browser is Safari?

I have a flash file that works in every browser except Safari. But if I empty the cache in Safari it works.

Upvotes: 1

Views: 924

Answers (2)

John K
John K

Reputation: 28917

Info about detecting and parsing the strings

https://developer.mozilla.org/En/User_Agent_Strings_Reference

To see your Safari OS X browser strings, visit this page with that browser http://show-ip.net/useragent/

Then use a JavaScript if to take action.

... but you won't be able to clear the cache via JavaScript (security).

However you can often vary the querystring of the resource to force it to reload instead of being taken from cache like:

  • first time: mything.swf?123
  • second time: mything.swf?abc
  • third time: mything.swf?I333

You can use a timestamp for a different number each time.

Upvotes: 3

kennebec
kennebec

Reputation: 104840

You can't force the cache to empty in any browser, but you can be sure a file is fetched from the server by adding a tail to the file path- url+'?'+new Date().getTime() is a good one.

Upvotes: 2

Related Questions