2

I have a js file which cannot be renamed as it's used by users who add a bookmarklet to their browsers. The js file is called from the bookmarklet.

I cache all js files on my site using cache-control within htaccess file.

So if I make a change to the js file in question, can i somehow force a users machine to recache that file?

Is there anything I can do within htaccess or anything like that?

New to me this...

StudioTime
  • 22,603
  • 38
  • 120
  • 207
  • Related: http://stackoverflow.com/questions/8347595 http://stackoverflow.com/questions/1207492 – sshow Nov 22 '12 at 13:36

2 Answers2

1

I'd set a Cache-Control: max-age=86400 instead of an expiry date if you're updating the file often.

But if you would do planned weekly deployments, you could set an Expires: header which points to a time at the end of the current week, so that it would expire right before your planned deployments, thereby making the browser downloading a new version of the file for all request after that point in time.

Another solution would be to start naming your files with version-numbers or appending query-strings to your bookmarklet JS URL.

sshow
  • 8,820
  • 4
  • 51
  • 82
0

In your bookmarklet code you could append, say, current date when including that JS file,

http://example.com/included.js?d=2012-11-22

and then re-route it in your .htaccess to whatever with a rewrite rule. Thus, you'll have a daily window of opportunity to push changes, without caching suffering much. May be good enough.

Ivan Krechetov
  • 18,802
  • 8
  • 49
  • 60