Jump to content

MAMP caching javascript file


Recommended Posts

I just started working on a basic game using Phaser.  I'm using MAMP and storing my game files in the htdocs folder.  I was working on the game yesterday and making changes to my javascript file using sublime and would be constantly refreshing my localhost page to see the changes.

Today, any changes to my javascript file are not being reflected.  I can change the index.html page and those changes are reflected on my localhost page but not the javascript which is located in the same game folder as index.html.  There must be some caching going on and I just can't figure out how to fix it.  Thanks for any help.

--UPDATE--

I just realized I was able to "force" my changes to be recognized by changing the name of the game folder in htdocs.  So finally it is recognizing changes I make to the javascript file.  Not a bad fix I suppose but it'd be nice to not have to do that everytime.

Link to comment
Share on other sites

There are a couple of levels of caching that could be interfering.

Browser level cache is easy to solve, most browsers have an option in their dev tools to disable local cache. Alternatively set headers correctly so that the browser never attempts to cache them.

The 2nd level could be some soft of in-memory cache to speed up file serving, not sure what Apache would do out of the box in MAMP but this sounds like something it might do. MAMP has a gui right? If so there will be configuration to disable it, you don't really need it in development anyway. Again, setting appropriate headers at the root should mean that files don't get cached. 

Config for apache can quickly get crazy.

Phaser is client-side so I'd suggest moving to an easier static development server, as you're a javascripter it makes sense to use a node based one as it'll integrate easiest with any tooling you have, there are loads on npm, most are zero config (tj/serve is a good one, its been supplanted by serve, which is used to be called, ha ha. I also have my own one called hench on npm). Python's SimpleHttpServer is also mentioned in some posts, but, honestly, why bother when there are better node ones available, most with live-reload and watch support.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...