Do not fetch app.manifest each time - javascript

For creating an offline version of a bunch of linked web pages I use an app.manifest-file that lists all the web pages for offline caching.
I would like it that the app.manifest file is not fetched every time when a user jumps from one web page to another. Most of the web pages will never be updated once the application is on the iPhone. Also the target audience is abroad so roaming costs could add up while users are using my "web app".
Searching the internet made me think in the direction of forcing an offline mode in Mobile Safari using Javascript but I don't know if this is the right way to go or if it is even possible.
Does anyone have any other and/or better ideas and suggestions on how to do this?

I would try setting an expires header to the future for the manifest file. That should theoretically prevent the browser from making a request for it. Never tried it, though.

Related

How to prevent user from opening the application in multiple browser tabs?

We are looking for a way to prevent users from opening the application in multiple tabs under the same browser.
The idea is to get plugged into one of the query Filter and then get access to the session maybe, and check if there is an already opened tab before proceeding.
I looked into httpSession and HttpRequest stuff but found nothing that can help.
Is there any functionality in the java side to know if the app is already opened in another tab?
thanks,
There's ways to accomplish this with Javascript.
See past questions / answers
How to prevent same website open multiple tab pages?
Stop people having my website loaded on multiple tabs
Preventing user from opening multiple tabs for the application
But all of those javascript techniques fail to work if ...
your user simply turns off Javascript.
they load the website from multiple browsers.
they load the website from normal and incognito modes on the same browser.
they load the website from multiple devices (laptop and cell phone).
You'll wind up with a mix of feature to attempt to prevent this (but it's a losing battle, and there's countless ways to get around it).
If you have a login, you'll want to track past logins and offer to disconnect / invalidate those other logins on a new login. (this will help with the multiple browsers and devices attempts). Your authorization layer on your server side will invalidate old sessions if they are attempted to be used.
If you have multiple tabs in the same browser, the javascript techniques from the old questions/answers are probably the best.
There are also people attempting to use websocket to act as the single point of communication, but I don't understand how that could work, but you'll come across it in your research.
From the server's perspective, it doesn't matter if the requests come from the same browser tab, different tabs, different browsers or different devices. Two tabs can share the same session. There is no way for the server (or the servlet) to know whether the request came from tab A or tab B. Tabs are a browser feature, it doesn't get sent in the HTTP header.
If you would elaborate on why you want to do this, I might be able to give a better answer.

Is it possible to using web api and open a local folder? [duplicate]

We are currently looking at porting a enterprise silverlight application over to html5. The major roadblock that we have hit is the ability to open files from the user's local disk. Currently they have a document library which just links to files on their computer that they can open from within the app and view or print out. All that I read is that you can only access the local sandbox of the web app with the html5 file api's. We want to load these files from code.
Does anyone know of any workarounds to this?
Thanks
There is no way for html5 to access local file without user selection. But FSO: FileSystemObject works for IE and MAYBE could be regarded as a work around. But still there are some requirements to meet.
It is possible to use chrome's filesystem API to access files on a users local filesytem. So you'd have to be willing to make this a chrome only application.
Using java you can create a "Signed" applet which has access to the local filesystem. (if the applet is signed you can request filesystm permissions)
then there is a tutorial for accessing methods of your java code directly from javascript here: http://docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html
you should be able to perform something similar from silverlight.
There is no workaround in pure HTML5/Javascript. You need the use of plugins, such as Java or Silverlight (maybe you shouldn't port it after all). As for workarounds, HTML5 gives you an easy way drag and drop multiple files that you could transfer on the server and then display back to your users. Another workaround would be to install a custom agent (a software with only a tray icon) that would send the information about the current user "document library" to server and then again, you could display it back to the user.
Note: I've heard somewhere that browsers will eventually stop supporting plugins. http://www.howtogeek.com/179213/why-browser-plug-ins-are-going-away-and-whats-replacing-them/
Ya, I agree with Markain. However, if you were to limit your audience solely to chrome users, I daresay, you would most likely use some of your users. If Huazhihao is right, then your number of leaving customers should decrease but users who regularly use firefox won't be happy. Overall, I think that this will not work. Otherwise, there would be too many websites that trashed your hard driver (or at least wherever you have the rights to edit/delete files). I think it would be best if your product was setup to synchronize the file whenever an internet connection was detected and a change was made to the file. That way the user would not need to visit the website whenever the file was uploaded. If this is some kind of an error file, then it would be most beneficial if you were to make a link in the application that when clicked, would upload the file to the website and the website were to do whatever was necessary. If this is a purely online thing, then I don't see what business you would have looking through other peoples' files =-). Hope I helped!

Getting camera and geolocation permission ahead of time

I'm building a web-app that uses the device's camera and location services. The browser (I'm sticking to Chrome for now) asks the user for permission to do so on the page where the service is used.
I want the interface to be able to ask for permission at an early stage in the workflow so the pop-up dialogs don't come up during the use of the app. I know they would go away after the first visit to a page, but I want to avoid it the first time too.
Javascript is pretty much the only tool I know how to use, and I know each page has a separate Javascript execution context, so I can't get references to the objects on one page and hand them over to another.
So is there a way that will work? Maybe I need to learn some other technology?
If you need to do it in the browser, then I would suggest creating a sort of initialization page before going to the actual app page.
In the ini page you can call all permissions and download+cache all needed app scripts and also validate which permissions were accepted and not. Kinda something like when using GMail you go through their ini page first before getting to the actual GMail ui.
Once the ini page has completely loaded simply redirect to the actual app.
If you want to do it outside the browser and still use the same web technologies, take a look at Electron or NW.js.
Both tools above lets you build cross platform desktop apps with web technologies. Things like asking for camera and geolocation can be done without user permission (as I recall. not sure)

Servier side and client side device detection

We are having two module of same web application in Servlet/jsp. One for mobile and one for desktop. I want to redirect to mobile version whenever an handheld device hit a desktop version. Since I am having two different context of same application, which will be the best approach for this. Server side device detection or client side detection and redirection.
Thanks in advance.
This is no different than redirecting between two different applications (or even two different servers). You might have good reasons for separating it like this, but I would consider having only one application, and using responsive design (media queries) for serving device adapted content. But if you really want to do it as you describe, I would do the detection on the server side, as doing it client side would rely on being able to execute javascript on the client, which may or may not be enabled or blocked.
But whatever approach you choose, please, please, please let the user override this by his/her own wish. And when doing the redirect, please, please, please don't loose the context the user was trying to access in the first place. The worst thing I know are websites that redirect to a mobile website after trying to reach a specific part of the website (typically an article), and then just being redirected to the root of the website, and then having to try to locate the part of the website (article) I was looking for...

Problem loading web pages that contain google adsense

This may not seem like a development question but there is a link.
I have been experiencing some issues loading some web pages from my development machine. They were painfully slow. I disregarded this until I tried running my own site and found that the culprit was the show.ad.js file provided by google adsense.
Using firebug I see that the page hangs on the loading of this file and then aborts after about 5-10seconds. If I am calling multiple database records to a page it will load one, hang, abort and then load another.
Trouble shooting I have done and things I can rule out are:
My router or any other external peripheral. If I go to any other PC in the house the page loads fine and very quickly. I have tried cabled and wireless. The problem appears to be something unique with my machine.
It is not just my website, it is all websites with google adsense.
I have turned off my firewall and shutdown anti virus. No change.
It is from all browsers on this PC. I have tried chrome, safari, firefox and ie. No change.
I do not have any ad blocker software installed that I know about.
I know there could be a million reasons why I could be having this problem but I thought someone out there may have had a similar experience. Failing that, is there any way I can trace the problem as I have no idea where to start.
Thanks in advance
Put it as far down in the page as possible to minimize interference with rendering other elements.
I've worked on high volume sites where we would intermittently experience issues loading Google and other 3rd party js; we determined that the issue was with the 3rd party servers, not us; the only thing you can do (other than turning off adsense) is to organize the page so that it renders even if you can't load the 3rd party components.
Have you checked your hosts file? There may be a bogus IP address for the AdSense host defined there. This file is plain text and is located at %SystemRoot%\system32\drivers\etc\hosts on Windows boxes, with no extension. (%SystemRoot% is typically C:\WINDOWS on a default install.)
Also, there may be a bad IP address in your DNS cache. Run ipconfig /flushdns to clear it.

Categories

Resources