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
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.
I made a webpage that should load a html files into a iframe. When you click something, it appears in . Although all of my files are html documents with html tags, they don't have extensions. So in the iframe, it renders as plain text. How do i configure Apache server setting so that the default file extension is set to ".html" when the file doesn't have any extension? Does it have anything to do with .htaccess file?
It seems like I can hide file extensions by doing some trick in that file, but I'm trying to do the opposite (adding an extension). How do I do this?
If you are using an old version of Apache:
DefaultType text/html
DefaultType Directive
MIME content-type that will be sent if the server cannot determine a type in any other way
For the current version:
Use the mime.types configuration file and the AddType to configure media type assignments via file extensions, or the ForceType directive to configure the media type for specific resources. Otherwise, the server will send the response without a Content-Type header field and the recipient may attempt to guess the media type.
So:
# force all files to be text/html:
<Location />
ForceType text/html
</Location>
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.
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