8797 sujets

Développement web côté serveur, CMS

Bonjour,

Je souhaite utilisé un script de Cache pour mon site dynamique.

J'en ai essayé un pas térrible au début, ensuite, j'ai entendu parlé beaucoup de JPCache. Je me penche donc sur ce script. Et je vois par la meme ocasion que Clubic.com utilise ce script (on peut le voir dans le header renvoyé avec le pluging developper pour Firefox) et il utilise JPCache avec son module MySQL.

Je décide donc de telechargé la meme version qu'ils utilisent, a savoir la v2.0 rc1.

Je lis le Readme qui indique :


0) Decide whether to go for the file- or database-storage.
    1) Edit jpcache.php and change the includedir-setting to the directory
       which contains the jpcache programfiles.
    2) Edit jpcache-config.php and change the configurationsettings. 
       Do not forget to uncomment the JPCACHE_TYPE setting for the storagemode
       you want to use.
       If you choose for filebased-storage, make sure that the directory is
       writeable for the apache-user (normally nobody)
       If you use the mysql-storage, enter the correct settings for accessing 
       the database.
    3) If you use the sql-version, create the database that is used for storing
       the cachedata (default name: "jpcache"). Within this database, create 
       the required table as provided in script.sql.
       You can use the mysql-client for this:
       mysql <db-name> < script.sql
       or you can use phpMyAdmin <http://phpwizard.net/phpMyAdmin> to read
       in the dump.
    4) You can easily test jpcache with the following file:
       <?php
        require "jpcache.php";
        echo time();
        phpinfo();
       ?>
       Request this file from you browser, refresh, and see if the time written
       is the same. 
    5) If everything works, edit your php-files and add (directly to the top):
            <? $cachetimeout=<X>; require "/path/to/jpcache/jpcache.php" ?>
       - Replace <X> with the number of seconds that the page should be cached.
       By default, pages will be cached for 900 seconds.
       - Setting <X> to -1 will disable caching and will only do content 
       encoding. Use this for pages which can not be cached, like personalized
       pages or with content that is always changing. Also when the page is 
       returning headers (like cookies in php), set the cachetimeout to -1, as
       header-information is not cached.
       - Setting <X> to 0 will create a non-expiring cache. This can be used 
       for pages that are not dynamic in content, but are heavy to generate.


0) je décide de faire un cache par ecriture de fichier sur le serveur
1) j'edit le fichier jpcache.php j'indique le repertoire de jpcache par rapport a la racine du site, donc /jpcache
2) j'edit le fichier jpcache-config.php et je décommente le type de cache, donc file.
le 3) me concerne pas, c'est pour mysql.
4) je test donc :

<?php
require "jpcache/jpcache.php";
echo time();
phpinfo();
?>

Et la les ennui commence, j'ai ce message d'erreur :


 Warning: Cannot modify header information - headers already sent by (output started at /web/test2.php:1) in /web/jpcache/jpcache-main.php on line 153


La ligne en question du code est :

        // Output header to recognize version
        header("X-Cache: jpcache v".$GLOBALS["JPCACHE_VERSION"].
                " - ".$GLOBALS["JPCACHE_TYPE"]);


C'est la partie qui je crois, envoie l'entete a la page.

J'ai également cree le repertoire /tmp/cache/ suite à ce commentaire dans jpcache-config.php :

    $JPCACHE_DIR          = "/tmp/jpcache"; // Directory where jpcache must store 
                                   // generated files. Please use a dedicated
                                   // directory, and make it writable


Mais cela ne change rien, rien ne s'ecrit dans le repertoire (j'ai bien mis en 777), et si je test avec MySQL, aucun changement, le message d'erreur reste avant le meme. A croire qu'il faut absolument trouvé pourquoi l'envoi du header marche pas avant de se penché sur mysql... Si quelqu'un a déja utilisé JPCache, ou a une idée du probleme, je vous remercie d'avance.

Ps, j'ai regardé sur le site officiel, y'a rien qui parle de ce probleme, j'ai également chercher avec Google d'autre explications, mais je tombe que sur des Bench... Smiley decu

Merci
Modifié par Okin (18 Aug 2005 - 18:38)