Well i remember something about the cache thing. What i want is to define some images do cache and some dont. I even want the browser to check if there is a new file instead of it to load or not. How do i do this ?
Tweak The Cache
I'm not sure If I completely understand your request, but from what I gather, you want to prevent cacheing of certain elements on your page correct? whether it be text or images. This is possible with Javascript preloading.
It is much easier to preload images than text.
Preloading Pages
Preloading Images
This site may have more information on the topic your looking for.
It is much easier to preload images than text.
Preloading Pages
Preloading Images
This site may have more information on the topic your looking for.
That information is incorrect. Preloading has nothing to do with this.
To prevent caching, set the following HTTP headers:
Some browsers will react to the first, some to the second, some to both.
Setting this can be done using PHP:
Although not preferred, you could also do it in HTML:
If you don't explicitly prevent caching, all browsers that support it will do it.
To prevent caching, set the following HTTP headers:
| Code: |
| Cache-Control: no-cache, must-revalidate
Expires: Mon, 26 Jul 1997 05:00:00 GMT |
Some browsers will react to the first, some to the second, some to both.
Setting this can be done using PHP:
| Code: |
| header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past |
Although not preferred, you could also do it in HTML:
| Code: |
| <META HTTP-EQUIV="expires" CONTENT="Mon, 26 Jul 1997 05:00:00 GMT">
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> |
If you don't explicitly prevent caching, all browsers that support it will do it.
If you decide to go with the HTML version be carefull on what are you using it , since some Search Engines (including Google and Yahoo) don't react nice to the pragma refresh and redirect Meta tags.
I recomend you use the PHP version.
I recomend you use the PHP version.
What i really want is configuring a cache tag or whatever. For example you have 5 images in a page and you want the browser to cache 2 of them but not cache the other 3.
| Kurosaki-Ichigo wrote: |
| What i really want is configuring a cache tag or whatever. For example you have 5 images in a page and you want the browser to cache 2 of them but not cache the other 3. |
You can't do that from html. However you can still do it with php, by sending a no-cache header with the images.
Something like this:
| Code: |
| <?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('Content-Type: image/png'); readfile('someImage.png'); ?> |
