How to stop a CSS file from loading again? - html

I have a very simple site and all the CSS for it is written in one file, so whenever any page is requested the CSS file is loaded. So I was wondering if there is someway, that I can tell the browser to use the same file it loaded a second ago instead of requesting it again.

I assume you have the css loaded externally then? I don't believe there is a way to natively do that unfortunately. But, if you're proficient in javascript, I suppose you could save all of the css file as a string using the localStorage property in the browser. Then request the data you want loaded specifically per site.
Local storage persists after the browser is closed, so it would only need to be loaded once!

Related

Is there any way of viewing large ppsx files in browser

I want to display large ppsx file in browser without downloading. Is there any way of doing that?
You need to have a plugin that knows how to interpret a ppsx file in the browser.
When the server pushes the file to you, it tells the browser the file type. It can also tell the browser to save the file instead of displaying it. In the second case I am not sure that you can stop it saving the file. In the first case if the browser doesn't have suitable plugin then it will save as a file.

Exclude page self by appcache

I have an appcache (with NETWORK *). So now I visit my page with <html manifest="/cache.appcache">. Then the page itself is cached as all the images are. But I want the page self to not be cached. How can I do this? I thought NETWORK * would do the trick.
Regards,
Kevin
The appcache manifest always caches the master page.
If you are using Chrome check the cached files for your page here: chrome://appcache-internals
A workaround could be to put a hidden iframe somewhere on your page, which contains the appcache file to cache offline content. (take a look at "Preventing the application cache from storing masters with an iframe" here: http://labs.ft.com/2012/11/using-an-iframe-to-stop-app-cache-storing-masters/ )
A better solution could be to write your page to fetch new content from your server when it is opened - if the server cannot be reached, it can serve the last known content from the HTML5 local storage.
I have tried the iframe work around, and find it ripe with errors. Most browsers cache the data for the iframe where the page cannot get it.
Instead make the page's content load via AJAX. Basically have a blank html page with the manifest and javascript which pulls and adds its content from the server. This way only the blank html is cached, and content is always updated from the server.
Converting a page to this method can be very difficult, but it works. Making sure the appropriate javascript gets run at the correct time, probably requires some detangling. Moving around server code which won't be called when pulling from cache to the new ajax method.
Note: no need to pull conditional content from the server if the condition is in the query string, different query strings make a separate cache

How to force caching of 10mb+ images so they never get reloaded?

I have a site which has 10mb+ of images (1000+ pngs) that have to be loaded before it starts. My current approach is loading every image in a hidden tag. How can I ensure that a client that accesses the site once/month, for example, will never have to download it all again?
No way. Client may have cache disabled, or he clears it every single minute
Compressed textures/generated textures/reused textures are how you should do it. You can't cache 10mb of images for a month reliably. If you need it for the game, then simply have a loading bar beforehand.
It sounds like you want to use an application cache. This means dealing with the page and its images as an application, with a cache manifest (.appcache file) listing them and the HTML document containing an <html manifest="..."> tag. See e.g. A Beginner's Guide to Using the Application Cache.

createBlobURL()

Is it true that if use createBlobURL(), file data is not loaded into memory? So is it alright to use it for images and video?
After looking at the WebKit source I would say the function only creates an URL in the following form:
blob:<encoded original url>/<uuid>
There doesn't seem to appear any loading of the URL's source.
The file contents are not loaded into JS memory, but the browser does create a handle to the file. So, calling createObjectURL() doesn't come for free. Chrome has a nice chrome://blob-internals/ page to see all the Blob URLs created.
Just remember to call revokeObjectURL() when you're done.

Loading images from various sources in QTWebKit

I am trying to create a "smart" web browser to load local images. Basically it works as a GUI for an application. I am using QTWebKit to power the browser, the problem is that the images of a given page can be found in different places, some are local files, others are in different resource files.
For example:
an HTML node to load image x.jpg can look like <img src="x.jpg"> and for image y.gif on the same page it can be <img src="y.gif">, now x.jpg is a local file that can be either in the root directory or in some other place. y.gif on the other hand can be in a resource file.
I want the web browser first to set the paths to all possible sources and once the page has been loaded or preferably while the page is loading searches for the images and loads them from their original path.
I considered the option of reading the HTML data first, parse it and search for the resources one by one, then edit the html to include the full path of the image but that would take a long time than what I want and it isn't practical.
Can any one put me on the right direction or does any one have any ideas on how such a design can be implemented.
EDIT: I have manage to delegate the requests by overriding the QNetwrokAccessManager and QNetwrokReply and been able to get the path to the image. The only problem is loading the image into view. I am currently using QHttp to handle the incoming requests but so far I haven't been able to load the image.
been trying to use QHttp's Get() function and passing the path to the jpg image as (file:///path/to/image) and also tried using the local path but nothing is working.
Take a look at How to tell QWebPage not to load specific type of resources?
You need the same approach but instead of dropping request by constructing QNetworkRequest with empty QUrl you need to pass url to the file on the disk.