9999 Posted December 4, 2007 Share Posted December 4, 2007 I have this code I want to give users to display on their websites or myspace pages. Its bascically some images. However, the content of one of the images changes daily even though its name will remain the same. <TABLE border=1> <TR><TD><IMG border=0 src="http://www.mysite.com/image1.gif"></TD></TR> <TR><TD><IMG border=0 src="http://www.mysite.com/image2.gif"></TD></TR> <TR><TD><IMG border=0 src="http://www.mysite.com/image3.gif"></TD></TR> <TR><TD><IMG border=0 src="http://www.mysite.com/image4.gif"></TD></TR> <TR><TD><IMG border=0 src="http://www.mysite.com/image5.gif"></TD></TR> </TABLE> Is there some simple code or script that I can include with my code to either prevent the images from caching and/or force a visitors browser to load current images? Thanks Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 4, 2007 Share Posted December 4, 2007 you cannot use javascript on myspace and if you are not using server side language to create the image (if your using a static image) and you cannot use a meta tag on myspace; then you cannot prevent image cacheing. If your not using dynamic images instead of static images and you cannot use code to control a site/page; then you really do not have any option. Because I know myspace does not allow JavaScript or Meta tags or Server Side Language; so your out of luck there. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 5, 2007 Share Posted December 5, 2007 Just add a paramater that you change daily (like the date): src=http://..../image1.gif?nocache=20071205 Whenever you change this param, the browser will be forced to get the new image. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 5, 2007 Share Posted December 5, 2007 Just add a paramater that you change daily (like the date): src=http://..../image1.gif?nocache=20071205 Whenever you change this param, the browser will be forced to get the new image. that would be allot of work and ineffective if you could not access the site someone else owned; that you had these pictures on. dynamic image - server side; is your best bet for this situation. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 6, 2007 Share Posted December 6, 2007 If you don't change the name of the image, the browser won't reload it. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 6, 2007 Share Posted December 6, 2007 I have this code I want to give users to display on their websites or myspace pages. you cannot change the image url on someone else's site; if you do not have administrative privileges. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 6, 2007 Share Posted December 6, 2007 Oh, I must have misunderstood... in that case, point the src to a php script that serves the image dynamically, still with the param for the same reason. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 6, 2007 Share Posted December 6, 2007 Oh, I must have misunderstood... in that case, point the src to a php script that serves the image dynamically, still with the param for the same reason. exactly......... Quote Link to comment Share on other sites More sharing options...
9999 Posted December 11, 2007 Author Share Posted December 11, 2007 Ok, sorry for not responding last week, I was out of town. I have created and uploaded 365 images (one for each day of the year). I name my orginal images like this: "dec11.gif", "dec12.gif", "dec13.gif", "dec14.gif" and so on.. Then I use this php script which we can call "daily.php" to match the current date (using the "Mj" date formatting system) to the image saved that corresponds to the date. It then creates the "image3.gif" and saves it to the server. I use CRON to automatically run this script at midnight daily. Code for "daily.php" <?php $im = imagecreatefromgif("".date("Mj").".gif".""); imagegif($im,"image3.gif"); ?> I then give out the code which references "image3.gif" Image3.gif is the only image that will always change every day. With this in mind, how would I implement the suggestions you guys previously mentioned so it would work not only on regular websites but social networking sites such as myspace that don't allow JavaScript, Meta tags, or Server Side Language. Thanks. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 11, 2007 Share Posted December 11, 2007 With this in mind, how would I implement the suggestions you guys previously mentioned so it would work not only on regular websites but social networking sites such as myspace that don't allow JavaScript, Meta tags, or Server Side Language. that was the point I was making - you cannot implement a no-cache code on any website that does not allow Client Side or Sever Side scripting languages or Metas. you probably can use a serve side image on most sites; like the script example you have: <img src="http://www.mydomain.com/pics/myPic.php"> - but you not going to be able to produce a random query string on the end of your image (which help prevent image cache). but for sites that do allow you to use your code - do something like this with your php code: <?php $currentday = date("z"); $im = imagecreatefromgif("".date("Mj").".gif".""); imagegif($im,"image". $currentday .".gif"); ?> Quote Link to comment Share on other sites More sharing options...
9999 Posted December 12, 2007 Author Share Posted December 12, 2007 ... point the src to a php script that serves the image dynamically, still with the param for the same reason. This is whtat I was refering to. Is there anyway I could point to the php script that I have or modify it so it would work for me? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 12, 2007 Share Posted December 12, 2007 yes - but since some social most social social networks and some websites do not allow javascript or server side scripting; you are not going to be able to use a random query string on the end of your image's src. however, most websites will allow you to embed a php image in their sites. you would do it like this: <img src="http://www.yourdomain.com/mypic.php"> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.