Cache total W3 - actualisation du cache par programme
6 réponses
- votes
-
- 2011-01-17
si vous souhaitez vider le cache,vouspouvez lefaire: leplugin a desfonctionspour ça
<?php flush_pgcache() //page cache flush_dbcache() // database cache flush_minify() // minify cache flush_all() //all caches ?>
et il vous suffit de l'appeler comme ceci:
<?php $w3_plugin_totalcache->flush_all(); ?>
et c'estessentiellement la réponse à la question dutitre "actualisation du cacheparprogrammation"
if you want to flush the cache you can do that: the plugin has functions for that
<?php flush_pgcache() //page cache flush_dbcache() // database cache flush_minify() // minify cache flush_all() //all caches ?>
and you just need to call it like this:
<?php $w3_plugin_totalcache->flush_all(); ?>
and that is basically the answer to the question in the title "cache refresh programmatically"
-
Pouvez-vous définirexplicitement comment vous avezinstancié l'objet $ w3_plugin_totalcache?Can you please explicitly define how you instantiated the $w3_plugin_totalcache object?
- 12
- 2014-02-27
- adamdport
-
Enpartie utile,comment avez-vousinstancié cette variable?Partially helpful, how did you instantiate that variable?
- 3
- 2017-01-23
- thephpdev
-
- 2014-03-20
Pour vider une seulepageparidentifiant depublication dans w3tc v0.9.3,j'aitrouvé que celafonctionnait:
if (function_exists('w3tc_pgcache_flush_post')){ w3tc_pgcache_flush_post($post_id); }
To flush a single page by post id in w3tc v0.9.3 I found this worked:
if (function_exists('w3tc_pgcache_flush_post')){ w3tc_pgcache_flush_post($post_id); }
-
Oùplaceriez-vous ce code?Cela semblefonctionner à chaque chargement depage (pour cet ID).N'existe-t-il aucunmoyen d'empêcher complètement lamiseen cache?Where would you place this code? This looks like it runs on every page load (for that ID). Is there no way to prevent to caching completely?
- 1
- 2014-03-20
- s_ha_dum
-
@s_ha_dum Pourriez-vous savoir avec quel hooknouspouvons utiliser ce code?@s_ha_dum Could you find out with which hook we can use this code ?
- 0
- 2016-11-17
- Prafulla Kumar Sahu
-
Des hooks supplémentairesne sontpasnécessaires si l'événement auquel votre code/pluginpersonnalisé sejoint s'exécute après le chargement desplugins,ce quiestgénéralement le cas.Toutes lesfonctions disponibles sont dans `w3-total-cache-api.php` dans le répertoire duplugin du W3TC.Extra hooks are not needed if the event your custom code/plugin attaches to executes after plugins have loaded, which is typically the case. All available functions are in `w3-total-cache-api.php` in the W3TC's plugin dir.
- 0
- 2018-08-01
- Walf
-
Merci,celam'a été utilemaintenanten décembre 2018. J'avaisbesoin d'unmoyen de vider le cache de lapage d'accueil unefois que le client a visité une certainepage (unepage deparamètres à afficher lorsqu'un agentest disponible).C'esttrès utilepour despages spécifiques,mais ce seraitbien s'il y avait unefonction qui viderait TOUS les caches comme lefait Purger All Caches!Thank you, this was helpful for me now in Dec 2018. I needed a way to flush the cache of the home page once the client visited a certain page (a settings page to display when an agent is available). This is very useful for specific pages, but it would be nice if there was a function that flushed ALL caches like the Purge All Caches does!
- 0
- 2018-12-01
- Jordan Carter
-
- 2011-01-17
W3 Total Cacheprenden charge lamiseen cache desfragments.De la FAQ:
How do I implement fragment caching? Edit your templates to with the following syntax to ensure that dynamic features remain so: Example 1: <!-- mfunc any PHP code --><!-- /mfunc --> Example 2: <!-- mfunc -->any PHP code<!-- /mfunc --> Example 3: <!--MFUNC --> echo rand(); <!--/mfunc --> Example 4: <!-- mclude path/to/file.php --><!-- /mclude --> Example 5: <!-- mclude -->path/to/file.php<!-- /mclude -->
W3 Total Cache supports fragment caching. From FAQ:
How do I implement fragment caching? Edit your templates to with the following syntax to ensure that dynamic features remain so: Example 1: <!-- mfunc any PHP code --><!-- /mfunc --> Example 2: <!-- mfunc -->any PHP code<!-- /mfunc --> Example 3: <!--MFUNC --> echo rand(); <!--/mfunc --> Example 4: <!-- mclude path/to/file.php --><!-- /mclude --> Example 5: <!-- mclude -->path/to/file.php<!-- /mclude -->
-
Merci Rast.Mais lorsquej'utilise l'un desexemples ci-dessus,j'obtiens uneerreur Erreur d'analyse:erreur de syntaxe,'<'inattenduThanks Rast. But when I use any of the above examples, I get an error Parse error: syntax error, unexpected '<'
- 0
- 2011-01-17
- user1567
-
@ user1567 vous avezprobablement uneincompatibilité avec lesbalises d'ouverture/fermeture ``.Jene les avaispasencore utilisés,doncje n'aipas d'extraitpratique àmontrer.@user1567 you probably have mismatch with opening/closing `` tags. I hadn't used these yet so don't have practical snippet to show.
- 0
- 2011-01-17
- Rarst
-
D'unepart,je voudrais chargerfunctions.php sans lemettreen cache. Le code suivant dansfunctions.php a déclenché l'erreur ci-dessus: require_once (functions2.php) ?> Quelest leproblème avec le code?For one thing, I would like to load functions.php without caching it. The following code in functions.php triggered the error above: require_once(functions2.php) ?> What is wrong with the code?
- 0
- 2011-01-17
- user1567
-
@ user1567 selon lesexemples,cela devrait être quelque chose comme `?> functions2.php@user1567 according to examples it should be something like `?>functions2.php
- 1
- 2011-01-17
- Rarst
Impossible demettreen cache desfragments detravail.Monproblème décritici: http://stackoverflow.com/questions/31125413/w3-total-cache-and-fragment-cache-not-able-get-it-to-workNot able to get to work fragment caching. My issue described here: http://stackoverflow.com/questions/31125413/w3-total-cache-and-fragment-cache-not-able-get-it-to-work- 0
- 2015-06-30
- JackTheKnife
- 2011-09-19
La solution de Bainternetne semblaitpasfonctionnerpourmoi.
J'utilise avec succès cetextrait de code alternatif dans unplugin,chargé à l'action admin_init :
// Clear all W3 Total Cache if( class_exists('W3_Plugin_TotalCacheAdmin') ) { $plugin_totalcacheadmin = & w3_instance('W3_Plugin_TotalCacheAdmin'); $plugin_totalcacheadmin->flush_all(); echo __('<div class="updated"><p>All <strong>W3 Total Cache</strong> caches successfully emptied.</p></div>'); }
J'espère que cela aidera quelqu'un là-bas.
Bainternet's solution didn't seem to work for me.
I'm successfully using this alternative snippet within a plugin, loaded at the admin_init action:
// Clear all W3 Total Cache if( class_exists('W3_Plugin_TotalCacheAdmin') ) { $plugin_totalcacheadmin = & w3_instance('W3_Plugin_TotalCacheAdmin'); $plugin_totalcacheadmin->flush_all(); echo __('<div class="updated"><p>All <strong>W3 Total Cache</strong> caches successfully emptied.</p></div>'); }
Hopefully this helps someone out there.
-
Jepeux confirmer que la solution de kevinlearynetfonctionne avec la version 0.9.2.4 de W3 Total Cache.Ilesttombéen pannepour [monplugin] (http://wordpress.org/extend/plugins/wordpress-bootstrap-css/) après cettemise àjour,et celafonctionne un régal.Je vous remercie! Paul.I can confirm that kevinlearynet's solution works with W3 Total Cache version 0.9.2.4. It broke for [my plugin](http://wordpress.org/extend/plugins/wordpress-bootstrap-css/) after that upgrade, and this works a treat. Thank you! Paul.
-
J'essaye d'exécuter ceci àpartir de la ligne de commande.Puis-je vous demander comment vous avez chargé la classe W3_Plugin_TotalCacheAdmin?J'aiessayé d'exiger wp-load.phpen vain.I'm trying to run this from the command line. Can I ask how you loaded the W3_Plugin_TotalCacheAdmin class? I tried requiring wp-load.php to no avail.
- 2
- 2014-02-26
- adamdport
- 2013-04-09
Aucune des solutions ci-dessusn'afonctionnépourmoi dansmonplugin.Cependant,cela afonctionné!Confirmation detravailpour la version 0.9.2.4 de w3tc.
if (function_exists('w3tc_dbcache_flush')) { w3tc_dbcache_flush(); }
J'aifait un " $ wpdb->get_results ("SELECT
sb_settings
.f_fb_app_id
,sb_settings
.f_fb_secret
FROMsb_settings
"); " et a été surpris que les valeursf_fb_secretet f_fb_app_id soient lesmêmes à chaquefois.C'était évidemment le cache w3tc du résultat de la requête.J'ai donc ajouté unflush dbcache dansmapage demodificationpour latable sb_settings.Si vous souhaitez vider le cache depage,utilisez simplement w3tc_pgcache_flush à laplace.
None of the above worked for me in my plugin. However this worked! Confirmed working for version 0.9.2.4 of w3tc.
if (function_exists('w3tc_dbcache_flush')) { w3tc_dbcache_flush(); }
I did a " $wpdb->get_results( "SELECT
sb_settings
.f_fb_app_id
,sb_settings
.f_fb_secret
FROMsb_settings
" ); " and was surprised the values f_fb_secret and f_fb_app_id was the same every time. It was obviously the w3tc cacheing the result of the query. So I added a dbcache flush in my modify page for the sb_settings table.Should you want to clear page cache, then just use w3tc_pgcache_flush instead.
-
J'aimerais que le votenégatifexpliquepourquoiil a voté contre.Y a-t-il quelque chose quine vapas dansma réponse?I'd like the downvoter to say why he downvoted. Is there anything wrong in my answer?
- 0
- 2013-04-12
- Elrinth
- 2012-02-11
Utilisez cetextrait de codepour vous assurer que votre PHPfonctionne,que lamiseen cache soit activée ou désactivée.Oui,vous devez écrire/appeler votrefonction deuxfois.
<!-- mfunc echo 'caching ON'; --><?php echo 'caching OFF'; ?><!-- /mfunc -->
(jepense) voici comment celafonctionne:
- Les conditionsmfunc remplacent lesbalisesphp.
- Si lamiseen cacheest OFF ,php à l'intérieur des commentairesmfunc apparaissent dans votrebalisage sousforme de commentaires HTML.
<!-- mfunc echo "hello?"; -->
Gardez cela à l'espriten fonction de votre degré de satisfactionpour lesgens de voir votre PHP (ne seproduit que lorsque lamiseen cacheest désactivée).
Use this snippet to make sure your PHP runs regardless of whether caching is on or off. Yes, you have to write/call your function twice.
<!-- mfunc echo 'caching ON'; --><?php echo 'caching OFF'; ?><!-- /mfunc -->
(I think) this is how it works:
- The mfunc conditionals replace php tags.
- If caching is OFF, php inside mfunc comments appear in your markup as a HTML comments.
<!-- mfunc echo "hello?"; -->
Keep this in mind depending on how happy you are for people to see your PHP (only happens when caching is off).
Je construis un site Web semblable à Digg dans WordPress.
Après avoirinstallé W3 Total Cache,j'ai remarqué que certains élémentstels que lenombre de votes (et lesidentifiants d'électeurs)parmessage sontmisen cachemême s'ilsne devraientpas l'être (dumoinspas après qu'un utilisateur votepour un article). Je suppose qu'iln'estpaspossible d'empêcher lamiseen cache d'éléments spécifiques d'unepage (ouest-ce?),J'ai doncpensé à déclencher l'actualisation du cache de lapageparprogrammation.
Des suggestions?