# Maybe a bit offtopic...how to prevent caching of game?\[\*urgent\]

**URL:** <https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160>\
**Category:** programming\
**Created:** [May 23, 2008, 5:02pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160 "2008-05-23T17:02:59Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluemagica](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@bluemagica](https://forum.kirupa.com/u/bluemagica)\
**Post date:** [May 23, 2008, 5:02pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/1 "2008-05-23T17:02:59Z")

</div>

i have a game that is supposed to read from a text file. but it generally reads the data from last time i played it. If i clear the cache of my browser, it loads correctly. How to solve this problem??

On a sidenote-- How do you make “subscript” text for a dynamic text?

---

<div class="post-metadata">

**Author:** ![bpalermo](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bpalermo](https://forum.kirupa.com/u/bpalermo)\
**Post date:** [May 23, 2008, 5:19pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/2 "2008-05-23T17:19:28Z")

</div>

I have seem this problem with php, what people normally do is passing a random parameter which doesn’t define anything, but makes the call unique.

I don’t think this would be possible to do using text files. But, then, I think you should rethink this approach of using text files, anyway.

---

<div class="post-metadata">

**Author:** ![bluemagica](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@bluemagica](https://forum.kirupa.com/u/bluemagica)\
**Post date:** [May 23, 2008, 5:24pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/3 "2008-05-23T17:24:59Z")

</div>

Actually my client is bent on text files… i have no alternative

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [May 23, 2008, 7:59pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/4 "2008-05-23T19:59:42Z")

</div>

> **[kirupa.com - Solve Cache Problems when Loading a Movie](https://www.kirupa.com/developer/actionscript/tricks/cache.htm)**
>
> Ensure that loaded movies are not cached versions stored on your hard drive.

Or you can use this cache manager extension:

> **[Community Trademarks - Furm](https://furm.com/trademarks/keywords/community)**

> [@bluemagica;2330203](#):
>
> On a sidenote-- How do you make “subscript” text for a dynamic text?

You can’t easily…you will probably have to embed a subscript font:

> **[kirupaForum](https://forum.kirupa.com)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [May 23, 2008, 8:45pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/5 "2008-05-23T20:45:40Z")

</div>

[ot]It’s worth noting that AS3 fixes this issue. URLLoader / URLRequest doesn’t have the same problem. Yet another reason to switch![/ot]

---

<div class="post-metadata">

**Author:** ![bpalermo](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bpalermo](https://forum.kirupa.com/u/bpalermo)\
**Post date:** [May 23, 2008, 8:49pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/6 "2008-05-23T20:49:05Z")

</div>

Actually his client demands he uses text… ■■■■ clients.

Anyway, the approach I told you before works for text too.

Here what I could devise:

```auto

function cacheClean(fCall) {
    if (!_url.indexOf('file')) {
        tResult = fCall;
    } else {
        var connector:String = (fCall.indexOf('?') < 0) ? '?cachecleaner=' : '&cachecleaner=';
        tResult = fCall + connector + new Date().getTime();
    }
    return tResult;
}

```

And here is the call:

```auto

lVar.load(cacheClean('data.txt'));

```

By the way, the “connector” bit is to allow you to use this function with other stuff in which case you may want to actually pass other parameters.

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [May 23, 2008, 8:54pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/7 "2008-05-23T20:54:23Z")

</div>

It’s still just a flat text file, it just has some extra formatting. I’m sure he could talk a client into that - if he’s good he’ll make it seem like he’s doing the client a favor. (Which he is.)

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [May 23, 2008, 9:32pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/8 "2008-05-23T21:32:52Z")

</div>

Whether it’s XML or text is immaterial - the file is still going to be locally cached unless he loads a unique version each time.

---

<div class="post-metadata">

**Author:** ![bpalermo](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bpalermo](https://forum.kirupa.com/u/bpalermo)\
**Post date:** [May 23, 2008, 9:41pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/9 "2008-05-23T21:41:55Z")

</div>

Not if he uses the function I presented above… =)

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [May 23, 2008, 9:49pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/10 "2008-05-23T21:49:24Z")

</div>

> [@bpalermo;2330316](#):
>
> Not if he uses the function I presented above… =)

You must’ve missed this part of my post “_unless he loads a **unique** version each time_” which is all the function (and the links I provided) does…it forces the browser to download a unique version of the file, whether that’s by appending a date, a random number, or 50 naked penguins to the end of the filename.

---

<div class="post-metadata">

**Author:** ![bpalermo](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bpalermo](https://forum.kirupa.com/u/bpalermo)\
**Post date:** [May 23, 2008, 10:13pm UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/11 "2008-05-23T22:13:56Z")

</div>

I didn’t. I just wanted to make sure he would get that the function worked, otherwise he might interpret your email wrongly and assume that the function didn’t do what you where saying should be done.=)

By the way, checked the links you posted, which I had completely missed before and would have saved me the time to come up with and test that function if I hadn’t. Nice ones.

Sorry if I stepped on a toe or something… :ne:

---

<div class="post-metadata">

**Author:** ![bluemagica](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@bluemagica](https://forum.kirupa.com/u/bluemagica)\
**Post date:** [May 24, 2008, 4:21am UTC](https://forum.kirupa.com/t/maybe-a-bit-offtopic-how-to-prevent-caching-of-game-urgent/261160/12 "2008-05-24T04:21:01Z")

</div>

Wow thanks a lot guys! I think this is fixed now!!

And Anogar if I used XML file, the end result would have been the same, since the problem was with caching! But thanks for trying…

Bpalermo, thankyou for your code, it made things more clear to me, and helped me understand exactly how to fix my problem!

glosrfc, i cant thank you enough for those links…especially the second one…

Again, thanks for being so kind and helpful guys!
