Page 1 sur 2

rafraichissement d'image apres upload

Posté : 20 mars 2008, 14:12
par chris51200
Bonjour a tous,
j'ai un soucis de rafraichissement d'image apres upload, mon code fonctionne parfaitement sous IE, sous firefox mais pas sous SAFARI...
pour resumé, j'ai deux pages sur lesquelles se trouvent 9 photos.
Apres un upload d'une photo, la nouvelle n'apparait pas immediatement. J'ai donc recuperer des astuces sur le net de type mettre un ?et un numero derriere le leins de l'image, cela fonctionne une fois sur deux sur SAFARI.
quelqu'un aurait il une autre astuce?
visiblement c'est la memoire cache qui ne se rafraichie pas assez vite...

Re: rafraichissement d'image apres upload

Posté : 20 mars 2008, 15:05
par AB
Bonjour a tous,
J'ai donc recuperer des astuces sur le net de type mettre un ?et un numero derriere le leins de l'image, cela fonctionne une fois sur deux sur SAFARI.
quelqu'un aurait il une autre astuce?
visiblement c'est la memoire cache qui ne se rafraichie pas assez vite...
tel que tu le dis c'est pas exactement la bonne syntaxe. Je pencherais plutôt vers une variable dans l'url qui a une valeur changeante à chaque click. Si c'est ce que tu as fais il n'y a pas de raison pour que cela ne fonctionne pas.

Posté : 20 mars 2008, 15:06
par Alkann
Je ne pense pas que ce soit un problème dû au PHP, mais tu peux essayer de mettre dans ta page un

Code : Tout sélectionner

<meta http-equiv="Pragma" content="no-cache">

Posté : 20 mars 2008, 18:19
par chris51200
Une variable a chaque click cela veux dire une valeur tournant?
je crois avoir vue que l'on pouvait affecter une valeur a laquelle ont affecte l'heure courante, c'est possible ça?
ou y a til une autre solution?
merci

[Note : ce message a été posté de manière anonyme avant d'être réattribué à son auteur]

Posté : 20 mars 2008, 18:44
par Ryle
Les scripts PHP génèrent souvent du HTML dynamiquement, qui ne doit pas être mis en cache, ni par le client, ni par les proxy intermédiaires. On peut forcer la désactivation du cache de nombreux clients et proxy avec :
Example#5 Interdire la mise en cache avec header()
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date du passé
?>
A compléter éventuellement avec ceux-ci:
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache"); 
Je ne sais plus lesquels servent vraiment, tu n'auras qu'à faire des essais :)

Posté : 20 mars 2008, 20:14
par chris51200
et si ma page est en html c'est quoi les codes a appliquer?

[Note : ce message a été posté de manière anonyme avant d'être réattribué à son auteur]

Posté : 20 mars 2008, 21:28
par AB
Alors renseignes toi sur les balises meta équivalentes à celles que t'a indiqué Ryle et essai par exemple

Code : Tout sélectionner

<meta http-equiv="expires" content="Wed, 31 Dec 2000 00 :00 :00 GMT"> <meta http-equiv="pragma" content="no-cache">
Sinon tu pourrais bien afficher la date dans une variable passée dans l'url mais il faudrait pour cela que ta page soit en php

Posté : 23 mars 2008, 18:51
par chris51200
merci de toutes vos reponses mais mon soucis est toujours la...
enfin ça fonctionne nickel sous IE mais sous SAFARI c'est la grosse zone.
Quelqu'un aurait il une explication?

Posté : 23 mars 2008, 20:20
par Hywan
Juste une intervention, s'il te plaît ne dénigre pas Safari. C'est sûrement (avec WebKit) un des meilleurs navigateurs du moment, alors ne dit pas que c'est la grosse zone :).

Posté : 23 mars 2008, 21:48
par chris51200
je ne doute pas des performance de SAFARI c'est juste que la il me crée des cheveux blancs....
Vous avez des astuces pour eviter la mise en cache des images?
tout ce que j'ai pu essayer jusqu'a maintenant ne fonctionne pas.

[Note : ce message a été posté de manière anonyme avant d'être réattribué à son auteur]

Posté : 24 mars 2008, 10:17
par chris51200
Voici mon code,
quelqu'un peux t il m'aider?
merci
<html> 

    <head> 
        <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"> 
        <title>Patrick LEGHIMA - Architecte d'Interieur - 24, rue d'Armaill&eacute; 75017 PARIS - tel:01.55.37.03.03- fax: 01.55.37.03.04 - [email protected]</title> 
        <csscriptdict> 
            <script><!-- 
CSInit = new Array; 
function CSScriptInit() { 
if(typeof(skipPage) != "undefined") { if(skipPage) return; } 
idxArray = new Array; 
for(var i=0;i<CSInit.length;i++) 
    idxArray[i] = i; 
CSAction2(CSInit, idxArray);} 
CSAg = window.navigator.userAgent; CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10); 
function IsIE() { return CSAg.indexOf("MSIE") > 0;} 
function CSIEStyl(s) { return document.all.tags("div")[s].style; } 
function CSNSStyl(s) { return CSFindElement(s,0); } 
function CSFindElement(n,ly) { if (CSBVers < 4) return document[n]; 
    var curDoc = ly ? ly.document : document; var elem = curDoc[n]; 
    if (!elem) { for (var i=0;i<curDoc.layers.length;i++) { 
        elem = CSFindElement(n,curDoc.layers[i]); if (elem) return elem; }} 
    return elem; 
} 

function CSClickReturn () { 
    var bAgent = window.navigator.userAgent;  
    var bAppName = window.navigator.appName; 
    if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0)) 
        return true; // dont follow link 
    else return false; // dont follow link 
} 

function CSButtonReturn () { 
    var bAgent = window.navigator.userAgent;  
    var bAppName = window.navigator.appName; 
    if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0)) 
        return false; // follow link 
    else return true; // follow link 
} 

CSIm = new Object(); 
function CSIShow(n,i) { 
    if (document.images) { 
        if (CSIm[n]) { 
            var img = (!IsIE()) ? CSFindElement(n,0) : document[n]; 
            if (img && typeof(CSIm[n][i].src) != "undefined") {img.src = CSIm[n][i].src;} 
            if(i != 0) 
                self.status = CSIm[n][3]; 
            else 
                self.status = " "; 
            return true; 
        } 
    } 
    return false; 
} 
function CSILoad(action) { 
    im = action[1]; 
    if (document.images) { 
        CSIm[im] = new Object(); 
        for (var i=2;i<5;i++) { 
            if (action[i] != '') { CSIm[im][i-2] = new Image(); CSIm[im][i-2].src = action[i]; } 
            else CSIm[im][i-2] = 0; 
        } 
        CSIm[im][3] = action[5]; 
    } 
} 
CSStopExecution = false; 
function CSAction(array) {  
    return CSAction2(CSAct, array); 
} 
function CSAction2(fct, array) {  
    var result; 
    for (var i=0;i<array.length;i++) { 
        if(CSStopExecution) return false;  
        var actArray = fct[array[i]]; 
        if (actArray == null) return false; 
        var tempArray = new Array; 
        for(var j=1;j<actArray.length;j++) { 
            if((actArray[j] != null) && (typeof(actArray[j]) == "object") && (actArray[j].length == 2)) { 
                if(actArray[j][0] == "VAR") { 
                    tempArray[j] = CSStateArray[actArray[j][1]]; 
                } 
                else { 
                    if(actArray[j][0] == "ACT") { 
                        tempArray[j] = CSAction(new Array(new String(actArray[j][1]))); 
                    } 
                else 
                    tempArray[j] = actArray[j]; 
                } 
            } 
            else 
                tempArray[j] = actArray[j]; 
        }             
        result = actArray[0](tempArray); 
    } 
    return result; 
} 
CSAct = new Object; 


// --></script> 
        </csscriptdict> 
        <csactiondict>             
<script><!-- 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button2',/*URL*/'Images/Pt2-off.jpg',/*URL*/'Images/Pt2-on.jpg',/*URL*/'',''); 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button9',/*URL*/'Images/Pt3-off.jpg',/*URL*/'Images/Pt3-on.jpg',/*URL*/'',''); 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button10',/*URL*/'Images/Gd1.jpg',/*URL*/'',/*URL*/'',''); 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button4',/*URL*/'Images/Pt4-off.jpg',/*URL*/'Images/Pt4-on.jpg',/*URL*/'',''); 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button5',/*URL*/'Images/Pt5-off.jpg',/*URL*/'Images/Pt5-on.jpg',/*URL*/'',''); 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button3',/*URL*/'Images/Pt6-off.jpg',/*URL*/'Images/Pt6-on.jpg',/*URL*/'',''); 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button6',/*URL*/'Images/Pt7-off.jpg',/*URL*/'Images/Pt7-on.jpg',/*URL*/'',''); 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button7',/*URL*/'Images/Pt8-off.jpg',/*URL*/'Images/Pt8-on.jpg',/*URL*/'',''); 
CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'button',/*URL*/'Images/Pt9-off.jpg',/*URL*/'Images/Pt9-on.jpg',/*URL*/'',''); 

// --> 

function MM_openBrWindow(theURL,winName,features) { //v2.0 
  window.open(theURL,winName,features); 
} 

function MM_goToURL() { //v3.0 
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false; 
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); 
} 
//--> 
</script> 
        </csactiondict> 
    </head> 

    <body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"  bgcolor="white" onload="CSScriptInit();"> 
        <div align="center"> 
            <table border="0" cellpadding="0" cellspacing="0" width="699" background="../Communs/Tab21.jpg"> 
                <tr> 
                    <td colspan="9"><img src="../Communs/Tab01.jpg" width="700" height="70" border="0"></td> 
                </tr> 
                <tr height="57"> 
                    <td width="130" height="57"><img src="../Communs/Tab02.jpg" width="130" height="57" border="0"></td> 
                     
      <td width="57" height="57"><img src="Images/Pt1-on.jpg" width="57" height="57" border="0" onDblClick="MM_goToURL('parent','../../formulaire.php?origine=resid&nimage=1&nchantier=1');return document.MM_returnValue"></a></td> 
                    <td width="14" height="57"><img src="../Communs/Tab03.jpg" width="14" height="57" border="0"></td> 
                    <td width="57" height="57"><csobj w="57" h="57" t="Button" ht="Images/Pt2-on.jpg"><a href="Page2.html" target="_self"><img src="Images/Pt2-off.jpg" name="button2" width="57" height="57" border="0"></a></csobj></td> 
                    <td width="14" height="57"><img src="../Communs/Tab04.jpg" width="14" height="57" border="0"></td> 
                    <td width="57" height="57"><csobj w="57" h="57" t="Button" ht="Images/Pt3-on.jpg"><a href="Page3.html" target="_self"><img src="Images/Pt3-off.jpg" name="button9" width="57" height="57" border="0" onDblClick="MM_openBrWindow('Page3.html','','')"></a></csobj></td> 
                    <td width="40" height="57"><img src="../Communs/Tab05.jpg" width="40" height="57" border="0"></td> 
                    <td width="16" rowspan="5"><csobj w="200" h="200" t="Button"><a href="/Chantier1/Big1.html" target="_blank"><img src="Images/Gd1.jpg" width="200" height="200" name="button10" border="0"></a></csobj></td> 
                    <td height="57"><img src="../Communs/Tab06.jpg" width="130" height="57" border="0"></td> 
                </tr> 
                <tr height="14"> 
                    <td colspan="7" height="14"><img src="../Communs/Tab07.jpg" width="370" height="14" border="0"></td> 
                    <td height="14"><img src="../Communs/Tab08.jpg" width="130" height="14" border="0"></td> 
                </tr> 
                <tr height="57"> 
                    <td width="130" height="57"><img src="../Communs/Tab09.jpg" width="130" height="57" border="0"></td> 
                    <td width="57" height="57"><csobj w="57" h="57" t="Button" ht="Images/Pt4-on.jpg"><a href="Page4.html" target="_self"><img src="Images/Pt4-off.jpg" name="button4" width="57" height="57" border="0" onDblClick="MM_openBrWindow('../../varsess4.php','','')"></a></csobj></td> 
                    <td width="14" height="57"><img src="../Communs/Tab10.jpg" width="14" height="57" border="0"></td> 
                    <td width="57" height="57"><csobj w="57" h="57" t="Button" ht="Images/Pt5-on.jpg"><a href="Page5.html" target="_self"><img src="Images/Pt5-off.jpg" name="button5" width="57" height="57" border="0" onDblClick="MM_openBrWindow('../../varsess5.php','','')"></a></csobj></td> 
                    <td width="14" height="57"><img src="../Communs/Tab11.jpg" width="14" height="57" border="0"></td> 
                    <td width="57" height="57"><csobj w="57" h="57" t="Button" ht="Images/Pt6-on.jpg"><a href="Page6.html" target="_self"><img src="Images/Pt6-off.jpg" name="button3" width="57" height="57" border="0" onDblClick="MM_openBrWindow('../../varsess6.php','','')"></a></csobj></td> 
                    <td width="40" height="57"><img src="../Communs/Tab12.jpg" width="40" height="57" border="0"></td> 
                    <td height="57"><img src="../Communs/Tab13.jpg" width="130" height="57" border="0"></td> 
                </tr> 
                <tr height="14"> 
                    <td height="14" colspan="7"><img src="../Communs/Tab14.jpg" width="370" height="14" border="0"></td> 
                    <td height="14"><img src="../Communs/Tab15.jpg" width="130" height="14" border="0"></td> 
                </tr> 
                <tr height="57"> 
                    <td width="130" height="57"><img src="../Communs/Tab16.jpg" width="130" height="57" border="0"></td> 
                    <td width="57" height="57"><csobj w="57" h="57" t="Button" ht="Images/Pt7-on.jpg"><a href="Page7.html" target="_self"><img src="Images/Pt7-off.jpg" name="button6" width="57" height="57" border="0" onDblClick="MM_openBrWindow('../../varsess7.php','','')"></a></csobj></td> 
                    <td width="14" height="57"><img src="../Communs/Tab17.jpg" width="14" height="57" border="0"></td> 
                    <td width="57" height="57"><csobj w="57" h="57" t="Button" ht="Images/Pt8-on.jpg"><a href="Page8.html" target="_self"><img src="Images/Pt8-off.jpg" name="button7" width="57" height="57" border="0" onDblClick="MM_openBrWindow('../../varsess8.php','','')"></a></csobj></td> 
                    <td width="14" height="57"><img src="../Communs/Tab18.jpg" width="14" height="57" border="0"></td> 
                    <td width="57" height="57"><csobj w="57" h="57" t="Button" ht="Images/Pt9-on.jpg"><a href="Page9.html" target="_self"><img src="Images/Pt9-off.jpg" name="button" width="57" height="57" border="0" onDblClick="MM_openBrWindow('../../varsess9.php','','')"></a></csobj></td> 
                    <td width="40" height="57"><img src="../Communs/Tab19.jpg" width="40" height="57" border="0"></td> 
                    <td height="57"><img src="../Communs/Tab20.jpg" width="130" height="57" border="0"></td> 
                </tr> 
                <tr height="122"> 
                    <td height="122" colspan="9" valign="top"></td> 
                </tr> 
            </table> 
        </div> 
    </body> 

</html> 
[Note : ce message a été posté de manière anonyme avant d'être réattribué à son auteur]

Posté : 24 mars 2008, 13:28
par Hywan
Je doute que l'on puisse mettre juste un partie des éléments d'une page dans le cache navigateur. Si tu utilises un cache fichier côté serveur : oui c'est possible, mais pas côté client.

Mais, les idées lancées ci-dessus ne fonctionnent-elles pas ?

Posté : 24 mars 2008, 13:40
par chris51200
et bien la solution qui fonctionnait le mieux mais pas à 100% etait le changement de nom des images a telecharger. Malheureusement certaines fois ça ne fonctionne pas et ça ralenti considerablement le chargement de la page..
je precise que je suis sur pc et que j'essai depuis un SAFARI qui tourne sous windows...
Je ne sais plus comment m'orienter?
cote cache ou cote changement de nom d'image

Posté : 24 mars 2008, 18:33
par Calimero
et bien la solution qui fonctionnait le mieux mais pas à 100% etait le changement de nom des images a telecharger. Malheureusement certaines fois ça ne fonctionne pas et ça ralenti considerablement le chargement de la page..
je precise que je suis sur pc et que j'essai depuis un SAFARI qui tourne sous windows...
Je ne sais plus comment m'orienter?
cote cache ou cote changement de nom d'image
Je te recommanderais d'oublier pour l'instant safari. Quoique certains puissent en penser, Safari est loin d'être parfait (en particulier la dernière version (3.1), et en particulier sous windows) et ne peut pas être une référence de compatibilité universelle.

Si ton site fonctionne correctement sur IE 6/7 et sur firefox, tu peux déjà satisfaire pas mal de monde (dont 100% des utilisateurs de windows), ce qui est déjà pas mal :-)

Posté : 24 mars 2008, 19:24
par chris51200
oui c'est aussi ce que je me dis mais la personne qui m'a demandé ce site utilise un mac avec SAFARI...
sinon effectivement il y a longtemps que j'aurais oublier cet OS...

[Note : ce message a été posté de manière anonyme avant d'être réattribué à son auteur]