I'm learning how application cache works, but I got a problem.
I created my manifest file and 'imported' it in my index.html.
In the offline.manifest file I added:
CACHE MANIFEST
34567.js
and in my index file:
<html manifest="offline.manifest">
I'm working on localhost, but when I tried to search the script, I get nothing.
I erased the cache too, but result is the same.
I read about creating an .htaccess file and I created it with this string:
AddType text/cache-manifest .manifest
But, where I'd put it?
Apache's .htaccess file, which configures the web server, can be placed anywhere in the directory tree so long as you write your directive paths correctly. Based on the syntax AddType text/cache-manifest .manifest you'd need to keep the .htaccess in the same directory as the .manifest file here.
See this very similar question via the StackExchange network.
If you are not serving the .manifest with the correct text/cache-manifest content type it will be ignored.
Related
Recently I review my .htaccess file and notice there are no AddType line for .exe and .htm file types, like below:
<IfModule mod_mime.c>
AddType application/octet-stream .exe
AddType text/html .htm
</IfModule>
However, the strange thing is that the browser still can download .exe file instead of showing it in browser. And showing .htm instead of download it. Why? And is it necessary to add "AddType" fro these two types?
These mime-types are most certainly already defined in the server config. Although not necessarily explicitly with the AddType directive.
However, the mime-type for .exe files is more likely to be defined as application/x-msdownload (or possibly application/vnd.microsoft.portable-executable), rather than application/octet-stream. See this related StackOverflow question: Which MIME type is correct for the .exe file?
These mime-types are listed in the mime.types config file (the location of which is defined by mod_mime's TypesConfig directive) that is read in by Apache/mod_mime at startup. mime.types contains a list of mappings of mime-type to file extension. For example:
application/x-msdownload exe dll com bat msi
text/html html htm
For the complete list:
https://github.com/apache/httpd/blob/trunk/docs/conf/mime.types
And for the official list of registered mime-types with iana.org, see:
https://www.iana.org/assignments/media-types/media-types.xhtml
the browser still can download .exe file instead of showing it in browser.
Browser's don't normally known how to handle ".exe files". If the browser receives a response with a mime-type (Content-Type header) that it does not understand it will most likely prompt to download/save it.
From what I userstand,
<html manifest="test.appcache" xmlns="http://www.w3.org/1999/xhtml">
that is a sample on how one would use the manifest property.
CACHE MANIFEST
CACHE:
# Offline cache v2
# html files
index.html
# css files
styles.css
# js files
main.js
and the above is a sample of the manifest file.
However, when I try to run it from my iTouch, the cache is not working.
I just want to ask if the server affects if certain html5 property work? because the server I am using is quite old.
Thanks in advance
You have to make sure that the server delivers the manifest file with a MIME type of
text/cache-manifest
This could be done (assuming you're using apache) by adding
AddType text/cache-manifest .appcache
to your .htaccess file in the directory the manifest is residing in.
How to make server to return manifest file with text/cache-manifest content type? By default, if I put it to the server and include into <html manifest="cache.manifest"> it is being loaded with type application/x-ms-manifest.
That's one of the reasons why the recommended extension for manifest files is now .appcache - Microsoft is already using .manifest for something else. To configure content types:
In IIS6 and below, add the MIME type mappings on the header tab of your virtual directory or web site properties (MS instructions).
In IIS7 and later, either go to MIME types in Features view or add a mimeMap entry under staticContent in your web.config like <mimeMap fileExtension=".appcache" mimeType="text/cache-manifest" />
you may include
AddType text/cache-manifest .appcache
in your .htaccess
or if you happen to use PHP you can send header information
header('Content-Type: text/cache-manifest');
Was having trouble caching an offline site on the iPad through GoDaddy hosting... Their mime type is incorrect for Safari support, so I simply made an cache.ASPX page:
<%#Page ContentType="text/cache-manifest" ResponseEncoding ="utf-8" %>
At the bottom of the page... Hope this helps someone!
You have to have a helicon file type .htaccess for it to work with IIS. Is can have an .htaccess file, just needs to be a # Helicon ISAPI_Rewrite configuration file
Version 3.1.0.82
I have seen some articles about HTML5 Manifest, which say that we must add manifest file to .htaccess with following line:
AddType text/cache-manifest .manifest
However, there is no any explnation what is the purpose of adding?
Where should I place this .htaccess file ? in the same folder where the manifest file is? and finally how can i make sure that it is added to .htaccess successfully?
Even if i do not create any .htaccess file, i only add this to my html file
<html manifest="site.manifest">
I can see the popup bar in firefox, asking that the website is asking to store data. So isn't it working without this .htaccess?
I'll appriciate if anyone can explain. Thanks.
You don't "add a manifest file" to .htaccess with that line. That line just tells Apache that files with the suffix ".manifest" will be of type text/cache-manifest. Apache tells the client about the file type in the HTTP content-type header. The HTTP content-type header is required for the browser/client to understand how to interpret the contents of the file. Refer:
AddType Directive # httpd.apache.org
The cache manifest in HTML5 # en.wikipedia.org
The cache manifest syntax # w3.org
Offline Web Applications # w3.org
I have been trying to use Server Side Includes on my website to save time writing code and be able to change site wide elements quickly and easily.
However i cannot seem to get them to work, either locally or on the Server.
I have set them up as .html files (with only the code needed and no html or body tags) in a "ssi" folder and am calling them in the appropriate locations in my .shtml files with:
<!--#include virtual="/ssi/<filename>.html" -->
but still nothing. Any ideas?
Is it Apache? Perhaps includes are not even enabled.
http://httpd.apache.org/docs/2.2/howto/ssi.html
To permit SSI on your server, you must have the following directive either in your httpd.conf file, or in a .htaccess file:
Options +Includes
Have you enabled SSI on the Apache server?
You should have something like this in conf/http.conf:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
This means that .shtml files are parsed for SSI commands (not .html) files. Then, you need to enable if fr your Virtual Host, or directory:
Options +Includes
It's possibly a path problem. Have you tried it without the leading "/" in front of "ssi"?