0

I am having web application which when loaded makes some XMLHttprequests to get some dynamic data.

Problem is that this webapp takes lot of time during first run, since it loads lot of resources online.

I want to make this first run fast by putting resources in application and using HTML5 appcache. After my changes it works now as most of resources can be loaded from HTML5 cache. I have added cache manifest to my app.

This is good but my app also makes few XMLHttpRequest. I know this data is dynamic but during first run I want to load this data from static resources. Is it possible that I can store this data in JSON format in JS or HTML files and when XMLHttpRequests are made it should pick from those static resources.

I researched a lot on internet but looks like its not possible, not able to came across a single example with the help of which I can be sure that this is possible.

Any suggestions guys?

anand
  • 11,071
  • 28
  • 101
  • 159
  • Run a simple http server on your development machine and set the http requests to connect to localhost to retrieve json from a text file. Test the html at http://localhost:80/blah.html otherwise the requests may not work. – Mardoxx Jun 25 '14 at 12:19

1 Answers1

0

I'd suggest you either

  1. Bootstrap the JSON data right in the HTML file's source code if it's generated dynamically
  2. Store the responses in localStorage and if the requests fail, fallback to that
Gregor
  • 2,325
  • 17
  • 27