 |
|
 |
Why not try setting a last-modified header? That's the correct way of doing this.
The hack you have detailed is pretty poor, but I have seen this used in practice in many websites, especially when loading XML into Flash. Consider this however; why not also change the hostname of the server whilst you're at it? You could have 1000's of DNS entries pointing to the same host. That should work.
It's ridiculous.
|
|
|
|
 |
|
 |
I don't want to use the last modified header because I don't want to affect other items on my page. This is the easiest way to do this.
|
|
|
|
 |
|
 |
It's the easiest and most inappropriate. It's a Non sequitur to state that this is appropriate to apply to one image. Break http, and you break the web.
|
|
|
|
 |
|
 |
You can change the last-modified header just for images but you may not want to change it for all images. Also, I have seen browsers IE and Firefox ignore the last-modified header and use the cache especially when you are doing some dynamic image swapping using javascript.
I know that you were trying to be funny by saying you can change the hostname. But really your example is closer to changing the last-modified header for each image than it is for what he is proposing.
It is ridiculous that you would post such a reply without really knowing what you are talking about.
|
|
|
|
 |
|
 |
Actually I do know what I'm talking about. I have been a professional web developer for 10 years now; I have been the sole developer for real-time sites serving over 9 million users per hour. I have encountered this "solution" many times which is always suggested by those who are lacking in knowledge of HTTP and I've had to demonstrate how this "technique" is wholly inappropriate. Perhaps you should restrict your comments to the realm of code! If you have nothing to contribute then there are other sites for you. My response is completely appropriate here; I state you should use HTTP headers to achieve the desired behaviour. You however have not contributed anything.
|
|
|
|
 |
|
 |
Since you were unable to see what I was trying to contribute. As I stated in my post, I have seen situations where the last modified header is ignored by the browser and the cache is used, especially when you are using javascript to swap out images. Therefore, this method of making sure the browser does not use the cache is acceptable. You state "this technique is wholly inappropriate." Why do you say that? Just because you think it should be done the other way? Or because there is a WC3 standard that states it should not be used? My guess is that since you are the sold developer on many sites you probably are not used to having someone else have an idea, and when they do you think it is dumb because it is not your way.
As other people have said your post would not be getting so much attention if you had been nicer about it. If you don't understand why your comment was taken as mean, well... that is a social skill that cannot be taught.
Also if you have shown documentation on why this method is so wrong, instead of just declaring you the best programmer in the land, it would also help.
Being a web developer for 10 years and the sole developer is not that impressive. I have met plenty of “developers” who have been around for 10 – 20 years who don’t really know what they are doing. I am not saying that you don’t know what you are doing, just an observation.
Anyway, I am not going to respond to this anymore. I have said my peace. Good luck in your development career. Hope I did not offend anyone.
|
|
|
|
 |
|
 |
Why must I refer to documentation? I've said it should be using Http headers? Do keep "niceness" out of this. This is a technical forum not a pick up joint.
You're trying to pick a fight; why don't you wait until recess!
|
|
|
|
 |
|
 |
You continually say that my example is incorrect, yet you have not provided an alternate sample.
You say you have been a web developer for 10 years. Whoop de doo. It's not relevant to the topic at hand. I have junior and senior developer working for my company that have plenty of experience.
You tell people that if they "have nothing to contribute then there are other sites for you", yet you have not posted a single article to this site. This is actually the first article you have ever posted a response to.
I have simply tried to pass on a useful piece of information to someone else who might find it useful. If you don't like it, you are more than welcome to post a reply, but put some thought into your reply. More than just "it's ridiculous". Otherwise, as you notice, people will call you out.
|
|
|
|
 |
|
 |
I gave my credentials because they were brought into question by Huenemeca. Do keep up. I am not concerned about people criticising me; I'm used to it, however having extensive experience (which gave me the insight into NOT using this technique) and ratified qualifications in the subject does seem to alienate the more inept engineers amongst us. This place is becoming less technical by the day with mentions of "niceness" and also people not even reading threads! It's not *that* difficult! I suspect it will only be a matter of time before I am compared to a Nazi!
Getting back to the issue the correct behaviour is to set the appropriate http headers and not create random uris! Do use HTTP to control caching. Period. That's what the transport layer is there for! Do please read http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html[^]
|
|
|
|
 |
|
 |
Ok, so you can provide a link to an article. The article says nothing about random uris. It also does not help the problem that we had faced.
Remember the page constraints:
1) The image name does not change, only the image itself (therefore it will still pull it out of the cache)
2) This is one of the few elements on the page that i don't want cached.
3) AJAX is involved on the page
4) K.I.S.S.
There is NOT a way to meet each of these requirements using HTTP headers. If there is, please enlighten all of us by placing an example, not just a link to some article you found on google by typing in "http, cache". The article you linked to is the top result by the way.
|
|
|
|
 |
|
 |
I've already stated one should use the last-modified header! This thread is a joke! I think I stated this in my first reply! If commentators weren't so interested in bolstering a hack, which appears to replace the facilities HTTP already provides us, then we might have found a lot less typing and a lot more engineering going on!
With regard to proxy servers/firewalls please refer to the Cache-Control http header.
|
|
|
|
 |
|
 |
Myself and other have already stated that the last modified header DOES NOT WORK in this scenario. It has been tried and has failed. Again, if you can show me a way to accomplish this using headers, by all means do so.
|
|
|
|
 |
|
 |
Have you tried setting the "Cache-Control" http header to "no-cache"?
Post a url so I can see this not working. I don't believe you.
This is a much better document than the one I posted earlier, but I was a little tied up!
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html[^]
modified on Wednesday, August 6, 2008 2:32 PM
|
|
|
|
 |
|
 |
Again, please see the requirements. There are other items on the page that need to be cached. Therefore no-cache will not work. I can't give you access to my clients Intranet, therefore no sample unless i create a page outside of the realm that it is in. And quite honestly, I feel no need to prove what I already know to be true.
As I stated in the original post, this article was strictly to help people overcome the same situation that I faced. I honestly did not think it would take up this much time. However, I will defend my code and programming skills anytime that it is questioned. If I am wrong, which has happened, I gladly admit fault.
|
|
|
|
 |
|
 |
Well, you don't need to apply the HTTP header to everything, just the image!
A better way to encourage developers to achieve this behavior is by describing the correct mechanism for which this was designed for; in this case it is HTTP.
|
|
|
|
 |
|
 |
If for some reason the author is forced to use the same image name, then adding a querystring value works extremely well and is not rediculous.
Assuming that all users will pick up a image change is not the proactive way to go.
Consider this:
I have found that many corporate proxy servers or ISPs will ignore image changes as well as javascript changes for .js files.
I know this for a fact, I have witnessed it.
You as the web author have no control over that.
Changing the name of the image is the best way, but this solution works well if you can't rename the image.
|
|
|
|
 |
|
 |
And what did your investigations into corporate proxy servers show?
|
|
|
|
 |
|
 |
taxexile what DOM specification or standard is this method breaking? If it works it works. If you are going to bad mouth someone please at least show the decency to back up or argument with documentation.
You would not be getting so much negative attention had you worded your argument more politely and respectful of the writer. Please don't turn Code Project into just another flame fest it's not needed, instead write a article yourself and argue your point.
|
|
|
|
 |
|
 |
I'm not flaming. I am stating this is an inappropriate hack! There are facilities in HTTP that you should use to manage the transport. If you don't get that, then, good luck to you!
In fact I'm saddened that my response was considered rude! Is this the code project or a bad-programmer's support group? jeez!
|
|
|
|
 |
|
 |
I don't think you understand HTTP properly. The last modified header is only a personal record for the web author's use. Whenever you modify a file, dont forget to update the last-modified setting in Iispache, then when you come to do your timesheets, you'll be able to use the last modified data for reference.
|
|
|
|
 |
|
|
 |