appcache is trying to cache all files - html

I'm trying to make a appcache file but got some problems... I've added the appcache file to the server, here is its content:
CACHE MANIFEST
CACHE:
scripts/jquery-1.5.1.min.js
But after refreshing the page I got all my web site files missing (styles, js scripts, images etc.), I mean they are not loading anymore and browser always try to get them from local cache. But what I want is just to cache some of them, I don't want to specify ALL my files in the appcache (to CACHE section or to NETWORK section), is this possible?

Don't use the HTML5 app cache for what you are trying to do.
Browsers already cache certain resources from a website and you can choose how the browsers should cache the files by manipulating the HTTP headers. For example, Stack Overflow loads their jQuery library from Google and Google sets the HTTP header: "Expires: Sat, 16 Mar 2013 05:41:47 GMT". Every website that links to this file won't have to download it anymore because the browser will keep it in it's cache for the next year.
For the files on your own website you will have to find out which webserver is running your site. For the Apache webserver follow these instructions, for IIS follow these instructions.

Related

Mediawiki: Links to open local files on the server doesn't work

I have MediaWiki installed on a synology server. I would like to create a link on the wiki that would allow opening of files on the same server.
Here are the steps I did to achieve this:
Added $wgUrlProtocols[] = "file://"; in LocalSettings.php
A test file on the server: file://myServerName/path/to/file/test.txt. Putting this URL in my chrome browser directly opens the file.
Create a page in MediaWiki with a link to this file using [[file://myServerName/path/to/file/test.txt]]
When I click on the generated wiki page, nothing happens. However when I hover on top of the link, it shows the correct URL.
Can someone please point out what additional steps I need to do to get this working?
The file:// protocol points to the file on your computer. I'm not fully sure, but I think you cannot use it to retrieve file from a different machine (read my comment below about samba shares).
From quick research it looks like Chrome browser blocks requests with file:// protocol, But browsers like IE should allow you to open those files. It is done because of security reasons so the malicious site cannot open local files without your permission. You might bypass that by installing a special plugin in Chrome (look for Enable file links)
Instead of using file protocol, make those files available via Synology WebStation, and then create links that point to the file via webstation (not via path on the server). With that approach, links attached on your MediaWiki pages will work as those will be regular links.
If you don't use the WebStation, you might also try with ftp:// links (use the FTP service), or link to samba shares - that's where the file:// protocol might work, but again - I'm not sure and I cannot test it as I do not use windows.
I think that the safest/easiest/fastest way is to expose those files via WebStation.
Source: https://en.wikipedia.org/wiki/File_URI_scheme
The file URI scheme is a URI scheme defined in RFC 8089, typically used to retrieve files from within one's own computer.

View files on linux remotely from browser

I have an HTML file that contains some data on different (text) files as well as where they are located locally on a linux machine.
This file is meant to be sent as an email, with the file locations being anchor tags.
I want to use my browser (Google Chrome) to view some files that are on that remote linux machine.
What I mean by that is the following:
View the HTML file in the browser of any PC (In this case multiple ones running windows)
When I click on the link, the file should open in browser (without downloading) as just plain text.
Basically I want to remotely view these files like how I can view anything on my local pc through my browser.
Is that even possible? If it is, please explain to me how it is done.
If not, can you suggest an alternative?
The Linux system that houses text files should have a server installed and firewall set. that serves required text files. Server can be any if you only need serving static files and not need any authentication or business logic. nginx and apache can do the job. and just in response header include
Content-Type: application/pdf
Content-Disposition: inline; filename="filename.pdf"
to force file to be viewed in browser.

How to create a hyperlink to shared network directory or file?

I've checked the following two related discussions:
1. How do I make a hyperlink to a local executable?
2. An URL to a Windows shared folder
3. File Url Cross Domain Issue in Chrome- Unexpected
4. Firefox Links to local or network pages do not work
The following links work when I visited the website on localhost. That is, http://localhost.
A Shared Network Directory
A Shared Network Directory
A Shared Network Directory
But when I visited with http://172.21.1.123, all of above links have no response.
The debug console shows that Not allowed to load local resource: file://172.21.1.123/DIR.
Test Environment (Both of them have the same result.):
- Chrome 28.0.1500
- IE 10
If it is due to the security reason, any configuration to turn off? Or any idea?
The reason that you cannot link to a network share from an external/hosted/live site is because of security features of latest browsers like Firefox.
You can only open local network shares from a local HTML document.
The only way around this is to install a plugin for your browser that removes or disables this security feature as far as I know.

Appcache Manifest not working

I have the following appcache manifest:
CACHE MANIFEST
# Cache Manifest timestamp: 1361723106
CACHE:
offline.html
offline2.html
offline.manifest.php
NETWORK:
*
FALLBACK:
/ offline.html
I am using this on my local installed server.
So when I load the index.html file which links to this manifest file, the consolse in Chrome shows me that all files are cached properly. When I now shut down my local server and try to access the index.html file again, then I see the content of that index.html file. I was expecting to be "forwarded" to offline.html. What am I doing wrong?
Thanks in advance!
Although you speak of an "index.html" file, I'm assuming you're accessing the resource like this: http://yourlocalservername/ .
The resource that links to the appcache manifest (in this case "/") is always included in the application cache. Fallback applies to resources which are not in the cache, so the result you get is expected.
The only way to show an "offline indicator" when accessing a previously cached resource, is to ensure the cached resource includes javascript code that actually checks if the browser is offline. You could check navigator.onLine and/or check with XMLHttpRequest to see if your server is reachable (and functioning).

HTML5 Cache Manifest Not uploading

I am working on an offline application in HTML and am having a problem using the HTML5 manifest. I am able to get it to download all the files and the manifest but when I change the manifest it does not do an update.
I see a record of the browser downloading the manifest in the web server log, and it does issue a bunch of progress events. However there is no record in the web server log of it downloading any of the files listed in the manifest nor do any changes show up in the browser.
This is with firefox 3.6.4.
Any ideas?
The manifest itself is still subject to normal browser caching rules, make sure you serve the manifest files with an expiry header set to immediate. You can do this on Apache in .htaccess with this:
<IfModule mod_expires. c>
ExpiresActive on
ExpiresByType text/cache-manifest “access plus 0 seconds”
</IfModule>
In the short term, try hitting Ctrl+F5 to force a full reload or clearing your browser cache.