Change mime type for html files under certain path - apache

we are having an issue with our CDN billing us for page views and they are considering all text/html mime types as an html page and a page view. however, we actually have java (jsp's) that are obviously text/html which do relate to a page view but we also have small .html files which get loaded by javascript into the page for dynamic content which is business controlled. I quick dirty way to fix the billing without having to go rewrite the whole contract with the vendor would be to change the mime type for the html files under a certain directory to something other then text/html. I was going to do with by editing the apache config. I a few question i have for this is:
1) What if i change the mime type to text/plain or something else for these files? is there any impact of doing this?
2) Is there any other valid html mime type thats nots text/html? I assume no.
3) Any other ideas to fixing this issue?
UPDATE
I was thinking about changing the html file to be served as application/javascript. What is the impact of doing this? Anything?

1) What if i change the mime type to text/plain or something else for these files? is there any impact of doing this?
If you change the mime type, the browser will not render it properly.
2) Is there any other valid html mime type thats nots text/html? I assume no.
SSI:
AddType text/x-server-parsed-html .shtml .sht
AddHandler server-parsed .shtml .sht
3) Any other ideas to fixing this issue?
Convert the small HTML files into JSON or XHTML5.

Are you sure akamai is charging you based on pageviews and not on bandwidth utilized ? You may want to talk to your akamai contact on this.

Related

X robots tag to noindex a single pdf file

I need tour help. I have the need to noindex a single pdf file. I know that if i wanted to noindex all pdf files it would be great to use the x-robots tag
<FilesMatch ".pdf$">
Header set X-Robots-Tag "noindex, noarchive, nosnippet"
</FilesMatch>
What about if i want to leave all the other pdf indexed and i want to noindex just one pdf file? the path of the file woul be something like that www.dominio.it/file.pdf
I know that using the robot.txt is not a solution since it just prevent the crawling but not the indexing. Thx in advace to whoever will help me.

Why is there a time span between different network requests?

I'm optimizing the loading times in a web app and I don't know what's the problem. Firebug's Net panel is showing time holes between requests.
Can someone explain me this chart?
The gap between the requests can have two reasons:
Time needed to parse the requested page
When you request a URL, the browser needs to parse the returned contents to check whether they contain URLs to other ressources like JavaScripts, CSS files, images, etc. Subsequently requested ressources need to be parsed, too. So e.g. CSS files can contain references to images. Though the contents of the CSS file first need to be parsed to get those URLs.
Dynamically requested ressources
Using JavaScript resources can be requested asynchronously. These requests can be triggered e.g. through AJAX or by dynamically inserting DOM nodes like <img src="xyz.png" alt=""> into the page.

Disable browser cache for displayed in an iFrame PDF by means of TCPDF

I am trying for hours to solve the following caching problem.
My application has the following structure (simplified):
index.php - main page (contains various input fields, submit button and an iframe for dispaying PDF content with the help of TCPDF)
generate.php - generates PDF file based on the supplied POST parameters and stores the file to the filesystem
viewer.php - Displays the PDF document (TCPDF libraries). The iframe loads this script to show the pdf file
The workflow is pretty simple - the user chooses some options and clicks the submit button on the main page. The selected parameters are sent per AJAX by POST to the generate.php script. The script generates the PDF file and stores it to the filesystem. At the end it returns the newly created/edited filename. The filename is fetched in the AJAX callback function, which then refreshes the iframe with the new/edited filename:
viewer.php?filename=NEW_OR_EDITED_FILENAME
Everything is working, but when the file is being replaced, sometimes (NOT ALWAYS), the browser shows the old pdf file, although the new version is on the hard drive. I tried the following solutions:
Add Meta tags to disable cache to the generated HTML by index.php and viewer.php
Disabling cache for jQuery AJAX calls by: jQuery.ajaxSetup({cache: false});
Adding some random string to the the filename parameter:
viewer.php?filename=FILENAME_RANDOMSTRING
The RANDOMSTRING is then removed from the script and the filename is extracted.
None of these solutions worked for me. Tested browsers are: Chrome 25.0.1364.152 and Firefox 19.0. Can someone help me with this?
Thanks in advance
Just had the same problem but after adding a random string it works perfect:
<iframe src="file.pdf?=<?=time();?>"></iframe>
After many hours of trying, the solution I found is to really generate a new file each time (Solution 3 from the question without removing the random string at the end of the file). As a result it was necessary to update the database and to delete the old files on every change. My initial intention was to avoid these actions, but unfortunately no other solution was found

How to hack the HTML response from Apache HTTPD?

I need to include some HTML fragments (into the HEAD element) for each page that is handle by HTTPD. Why? I need to hack some natives javascript functions for security policy needs.
Thank you.
You could use mod_include http://httpd.apache.org/docs/2.2/mod/mod_include.html if you can edit your existing HTML files. If you don't want to do that, you will need to create a custom filter to post process the HTML. You can add the custom filter with mod_filter https://httpd.apache.org/docs/2.2/filter.html

Can I force all links in a WebView (or WebFrame) to be treated as absolute paths?

So I'm working with WebKit's - WebView and WebFrame. I use a custom NSURLProtocol to retrieve the HTML for each request from a database. The problem arises from the fact that the links in the HTML are all relative, when they really ought to be absolute. For example, the page
foo/bar.html
May have a link in it that points to
foo/baz.html
The problem is that since the link is relative, the request ends up being for
/foo/foo/baz.html
So far, I've tried to work around this by comparing the two URLs and stripping off the common prefix - in this case 'foo/' - leaving me with foo/baz.html. This doesn't work for all possibilities, however, especially when there are multiple directories in the path. I do this in the "didStartProvisionalLoadForFrame:" method of my WebView's frameLoadDelegate.
Unfortunately, I do not have control over the HTML that I'm displaying, so modifying the links themselves is not an option.
Try being the main frame's resource load delegate, and implementing webView:resource:willSendRequest:redirectResponse:fromDataSource: to modify the URL being requested. Send relativeString to the request's URL to get the original relative URL, then use -[NSURL initWithString:baseURL:] to create a new URL with the same relative string against the correct base URL.