Can someone show a complete example of application cache with html, css, js, appcache file including CACHE, NETWORK and FALLBACK section. Also updating the manifest. Where should the coding be written?
http://www.html5rocks.com/en/tutorials/appcache/beginner/#toc-updating-cache
As per updating cache from the above link, where should the coding been written?
The code for updating the manifest is written by your sever somewhere.
Either in PHP or Node.js you must write and serve this file with the correct mime type as specified in the link you posted.
You can auto generate this from the css and js files on your server. Don't include html files unless they are dynamic pages.
The first line in the file must be CACHE MANIFEST
Now it assumes your are putting things into the CACHE section, which is where you need to include all the paths to your css and js that you want the user to be able to use offline.
To create a NETWORK section, simply print out the word on it's own line.
Under this section you should include pages that should only be used online.
Under the FALLBACK section include a page to show if there is no offline version available.
This is a brief explanation but you should be able to easily find a tutorial that will help you auto generate this file.
For more details about the cache manifest itself:
http://diveintohtml5.info/offline.html
Offers the best explanation IMHO.
Related
I always see these few files under the Scripts directory:
ai.0.22.9-buildXXXXX.js
ai.0.22.9-buildXXXXX.min.js
jquery-[version #].min.map
According to this answer, I can wipe out the Scripts folder. But I usually leave these 3 files alone, because I am afraid of bad consequences.
So What are the purposes of each file?
Microsoft Application Insights JavaScript SDK
Application Insights tells you about your app's performance and usage.
By adding a few lines of code to your web pages, you get data about
how many users you have, which pages are most popular, how fast pages
load, whether they throw exceptions, and more. And you can add code to
track more detailed user activity. ai.0.22.9-buildXXXXX.min.js can be
removed if you dont need to view site statics
For more details on how to use it
jquery-[version #].min.map
It is used for Source Mapping
Consider when you start debugging and you are on the particular line.
And you press (F11 or Click Step into Next Function Call), the
debugger tool will take you to jquery.min.js. And looking at jquery
minified version, it is impossible to find out the error. But with
source maps, you can let the browser’s debugger "map" the lines in the
compressed file into the uncompressed source. For Source map to work
successfully, two things are required.
1. Value of sourceMappingURL exists on your server or locally.
2. Browser Support
For further details
if you don't need it you can remove it
ai.*.js files are for Application Insights. Not required and can be removed, unless if using Application Insights.
*.map are for debugging purposes of JavaScript files. I doubt it will be necessary to debug the jQuery plugin. Not required and can be removed.
I am developing a share extension for iOS 8 and it seem like i can run javascript code on page to grab some information like markup of the mage
But on the apple document it says that javascript code must be inside a .js file but my javascript code is coming from server and it is dynamic.
Is it possible to run javascript i downloaded from server or can I change js file contents everytime I need to use it?
You can't do this using the built-in support in the current share extension system.
The Javascript file needs to be listed by name in the extension's Info.plist, in the value of the NSExtensionJavaScriptPreprocessingFile key. The file named there needs to exist in the app extension's bundle. But bundles are not writeable, so you can't replace or change the file.
You might be able to do something like you describe if you:
Include a basic JS file that just returns the entire page source to your extension.
Use JavaScriptCore.framework to further process that data in your extension.
I don't know of any reason why that wouldn't work, but I haven't tried it, and it's kind of unusual. Still, given your needs, it's worth investigating.
I use Rails 4 with rack-offline to cache my pages. I also want to cache (dynamically generated) html pages for offline browsing. Problem is, with the way HTML5 works, they stay stale until the application manifest is updated.
The docs say:
In production, it generates a SHA hash once based on the contents of
all the assets in the manifest. This means that the cache manifest will
not be considered stale unless the underlying assets change.
Is there any way I can trigger a new hash generation when one of my html pages change? This would, for example, after a database update.
Probably not, because AppCache is meant for static resources. Best to use a static HTML page, and use JavaScript to load in dynamic content.
Check out appcachefacts.info for more information.
Simple question, could'nt find a straight answer. How can I modify the output file name of a T4 Template?
I'm using a T4 Template to bundle and minify all my javascript files. Now I want to include the current Assembly Hashcodein my filename. But how can I access this filename?
A workaround would be to rename the ouput file after generating it but this doesnt't seem nice to me.
You need to do something called auto-versioning, and this is usually done by URL rewriting. The physical files are not actually renamed.
See this question for details on javascript and css auto versioning:
How to force browser to reload cached CSS/JS files?
Note that if you use templates to generate a different physical file for every time you generate a file then you will lose a lot of benefits of source control (revisions etc), and you will end up with an unmanageably large set of files on disk.
Does anyone know why there are question marks (with a number) after the images and css files (when looking at the html code)? And how can I turn them off?
From Rails API documentation:
By default, Rails will append all
asset paths with that asset‘s
timestamp. This allows you to set a
cache-expiration date for the asset
far into the future, but still be able
to instantly invalidate it by simply
updating the file (and hence updating
the timestamp, which then updates the
URL as the timestamp is part of that,
which in turn busts the cache).
Hope it helps.
It is to be able to cache the file on the client and still making sure the client receive the newest version when there is a change. So each file modification results in a new timestamp which the client will do a new request to the server to receive the modified file.
If you do not want to use (though I cannot see why - it is a good thing) simple do not use the rails helpers for including javascripts or stylesheets. Just include the normal HTML tags: link and script.