LinkedInAttic/inject

Setting setExpires(0) in dev

jeromecovington opened this issue · 4 comments

Hi, I have my dev setup with Inject.setExpires(0) yet I still have to do localStorage.clear() when I change my JavaScript (in addition to clearing the cache).

Hi @jeromecovington. Do you have a live page or dev page I can look at? Some common pitfalls around setExpiers that I know of

  • If you call setExpires(0), it needs to be done before your first requrie() or define() calls, otherwise it writes it in to localStorage anyway
  • In IE 7, the userData shim can become corrupted if writing to it from multiple windows at the exact same time

In reply, can you also include your Inject version string by using the following code after Inject has loaded?

alert(Inject.version)

This will give me an exact git revision ID to test with on my side.

Live URL:
http://www.people.com/people/static/h/test/people-code/on-the-surface-v2/index.html

Inject.version:
v0.4.2

Thanks!

On Mon, Apr 29, 2013 at 2:28 PM, Jakob Heuser notifications@github.comwrote:

Hi @jeromecovington https://github.com/jeromecovington. Do you have a
live page or dev page I can look at? Some common pitfalls around setExpiers
that I know of

  • If you call setExpires(0), it needs to be done before your first
    requrie() or define() calls, otherwise it writes it in to localStorage
    anyway
  • In IE 7, the userData shim can become corrupted if writing to it
    from multiple windows at the exact same time

In reply, can you also include your Inject version string by using the
following code after Inject has loaded?

alert(Inject.version)

This will give me an exact git revision ID to test with on my side.


Reply to this email directly or view it on GitHubhttps://github.com//issues/255#issuecomment-17184789
.

Regards,
Jerome
Music http://www.jeromecovington.com/music/ || Web
Devhttp://www.jeromecovington.com/dev/

Confirmed as a bug.

The issue is actually in how we're using lscache by @pamelafox See https://github.com/pamelafox/lscache/blob/master/lscache.js#L187

Since it's a loose check with the time variable, a setExpires() of 0 won't work since we just pass things down directly.

In Inject, we'll wrap the lscache.set() in Communicator to test for a pure 0 case.

Adding @fsimeon for the review.

In the meantime, a really lame workaround is to use setExpires(1) and try not to refresh in the same second.