Changeset 2244316
- Timestamp:
- 02/14/2020 09:04:24 AM (6 years ago)
- Location:
- ergonet-varnish-cache/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
varnishCache.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ergonet-varnish-cache/trunk/readme.txt
r2244308 r2244316 36 36 Once Varnish cache system is activated from Ergonets WebPanel and Ergonet Varnish Cache plugin is installed and activated, it will work without any additional configuration. 37 37 38 ** Caching resources ** 38 Caching resources 39 39 A resource, intended as an URL, will be automatically added into Varnish cache when an anonymous user visits the page. 40 40 41 ** Updating cached resources ** 41 Updating cached resources 42 42 Whenever the webmaster updates an article or page, the plugin will take care of deleting the old resource in the cache, to prevent users from viewing old content. 43 43 At the same time, homepage cache will also be deleted and updated with last articles. 44 44 45 ** Clearing Cached Resources ** 45 Clearing Cached Resources 46 46 Given the automatic update and removal of resources, there will be no need to forcibly clear cache. Furthermore, total cache deletion is a not recommended action, as it would delete all resources (pages, articles, etc.) that have been stored previously since they were heavily visited. 47 47 On sites with a lot of content, total cache deletion could also cause a significant slowdown, due to the need to regenerate from scratch all WordPress pages or articles requested by users. … … 73 73 The response headers will open in the right column, last header will be the one related to Varnish: 74 74 75 ** X-VC-Cache: HIT **= the resource, therefore the page called, is available in cache and has been returned by Varnish. It means that the cache system is working properly.75 X-VC-Cache: HIT = the resource, therefore the page called, is available in cache and has been returned by Varnish. It means that the cache system is working properly. 76 76 77 ** X-VC-Cache: MISS **= the resource, therefore the page called, is NOT available in cache and was generated by WordPress application. It means that the cache system has been instructed by the application headers or by custom rules, not to return the content from cache.77 X-VC-Cache: MISS = the resource, therefore the page called, is NOT available in cache and was generated by WordPress application. It means that the cache system has been instructed by the application headers or by custom rules, not to return the content from cache. 78 78 79 79 == ACTIVATION OF VARNISH CACHE SYSTEM FROM WEBPANEL == 80 80 From Ergonets WebPanel additional Varnish configurations are available: 81 81 82 ** Cache expire ** 83 * Recommended configuration: 1 week * 82 Cache expire 83 Recommended configuration: 1 week 84 84 Time retention of a given resource in cache. After this time, the resources available in Varnish cache that have reached this retention period will be deleted. 85 85 Remember that a resource (for example a page or an article), if modified or updated, will be deleted from the default cache, without considering its validity time and without the need to clear the entire cache. Whenever you update a page or article, homepage cache will also be invalidated. 86 86 87 ** Force cache ** 88 * Recommended configuration: OFF * 87 Force cache 88 Recommended configuration: OFF 89 89 Some plugins or themes forces Cache Control headers to not allow Varnish to cache a resource. It is always preferable not to force this directive, as the headers are expected to be correctly set by applications, themes and plugins developers. 90 90 If activated, carefully check that there are no unexpected issues on website. 91 91 92 ** Dedicated memory (option only available on dedicated Cloud Hosting) ** 93 * Recommended configuration: 128MB * 92 Dedicated memory (option only available on dedicated Cloud Hosting) 93 Recommended configuration: 128MB 94 94 Amount of RAM memory assigned to Varnish cache; 128MB is enough for most websites. For portals or e-commerces with a lot of content or products, we suggest setting it to 256MB or 512MB. 95 95 Keep in mind that the more RAM you will assign to Varnish, the less it will remain available for all other websites hosted on the same server and for the operating system. Increase the amount of Varnish RAM only if you have enough memory available. 96 96 97 ** Terms to exclude ** 97 Terms to exclude 98 98 Terms and words that if found on URLs should exclude content from being cached. There are already some default terms, but the list can be enriched if necessary by the user. 99 99 == Installation == 100 100 101 1. Activate varnish cache support on Ergonet **WebPanel**control panel.101 1. Activate varnish cache support on ErgonetWebPanelcontrol panel. 102 102 2. Upload the plugin files to the `/wp-content/plugins/plugin-name` directory, or install the plugin through the WordPress plugins screen directly. 103 103 3. Activate the plugin through the 'Plugins' screen in WordPress. … … 105 105 == Changelog == 106 106 107 = 1.0.3 = 108 Add plugin information. 109 107 110 = 1.0 = 108 111 Plugin first release. -
ergonet-varnish-cache/trunk/varnishCache.php
r2233758 r2244316 6 6 Plugin Name: Ergonet Varnish Cache 7 7 Description: Plugin per la gestione della cache Varnish su hosting Ergonet. Al momento dell'aggiornamento di un articolo/pagina, il plugin provvede a cancellarlo dalla cache in modo da fornire agli utenti sempre l'ultima versione del contenuto. 8 Version: 1.0. 28 Version: 1.0.3 9 9 Author: Ergonet srl 10 10 Author URI: https://www.ergonet.it … … 42 42 function init() 43 43 { 44 add_action( 'save_post', array($this, 'purgeCache'));45 add_action('admin_bar_menu', array ($this, 'adminBarMenu'), 99);46 add_action('admin_footer', array ($this, 'cache_purge_action_js'));47 add_action('wp_ajax_varnish_cache_purge_homepage', array ($this, 'cachePurgeHomepageCallback'));48 add_action('wp_ajax_varnish_cache_purge_all', array ($this, 'cachePurgeAllCallback'));49 add_action('admin_menu', array ($this, 'pluginInfo'));44 add_action('save_post', array($this, 'purgeCache')); 45 add_action('admin_bar_menu', array($this, 'adminBarMenu'), 99); 46 add_action('admin_footer', array($this, 'cache_purge_action_js')); 47 add_action('wp_ajax_varnish_cache_purge_homepage', array($this, 'cachePurgeHomepageCallback')); 48 add_action('wp_ajax_varnish_cache_purge_all', array($this, 'cachePurgeAllCallback')); 49 add_action('admin_menu', array($this, 'pluginInfo')); 50 50 } 51 51 … … 57 57 function pageContent() 58 58 { 59 echo "<h 1>Ergonet Varnish Cache</h1>";59 echo "<h3>ERGONET VARNISH CACHE FOR JOOMLA</h3><p>Ergonet Varnish Cache for Joomla! è il plugin gratuito sviluppato da Ergonet srl, azienda di hosting italiana, per migliorare drasticamente le performance di un sito web sviluppato in Joomla!.</p><h3>BENEFICI</h3><p>L’utilizzo di un sistema di reverse proxy basato sull’acceleratore web Varnish aumenterà le performance del tuo sito in Joomla! da un minimo del 30% ad un massimo del 60%. Ricorda che la percentuale di miglioramento dipenderà comunque anche dall’intera strategia di ottimizzazione del tuo sito web.</p><h3>COS’È VARNISH?</h3><p>Varnish è un acceleratore http (detto anche reverse proxy) che salva intere pagine del tuo sito in Joomla! nella memoria RAM, il supporto più veloce che ancora oggi esista, restituendole immediatamente al visitatore del sito web.</p><p>Se quindi una determinata pagina del tuo sito è già stata visitata in precedenza ed è quindi presente in cache, Varnish la restituirà immediatamente all’utente che la sta richiedendo, senza richiederne nuovamente la generazione al tuo sito in Joomla!.</p><p>Qualora un visitatore visitasse una pagina non ancora presente in cache, Varnish la richiederà direttamente al web server Apache/NGINX, inserendola nella cache per velocizzare una possibile futura nuova richiesta della stessa.</p><h3>COMPATIBILITÁ</h3><p>Ergonet Varnish Cache è compatibile con tutti gli altri plugin di cache e ottimizzazione del sito web. Ad esempio JCH Optimize e JotCache.</p><p>Il plugin Ergonet Varnish Cache funziona esclusivamente come layer di comunicazione tra Joomla! e il sistema di cache Varnish installato sulla piattaforma server di <b>hosting per Joomla! con profilo Successo e cloud hosting dedicati (Solo e Multidominio)</b> di Ergonet disponibili per l’acquisto sul sito https://www.ergonet.it</p><p>Un requisito fondamentale per il funzionamento del plugin è l’attivazione del sistema di cache Varnish dal WebPanel (area clienti Ergonet disponibile su https://webpanel.ergonet.it) da parte dell’utente che ha acquistato il servizio di hosting condiviso o cloud dedicato.<p><h3>COME FUNZIONA IL PLUGIN</h3><p>Una volta attivato il sistema di cache Varnish dal WebPanel di Ergonet e installato e attivato il plugin Ergonet Varnish Cache, lo stesso funzionerà senza alcuna configurazione aggiuntiva.</p></b>Inserimento delle risorse in cache</b><p>Una risorsa, intesa come URL, verrà inserita nella cache di Varnish nel momento in cui un utente non loggato visiterà la pagina.</p><b>Aggiornamento delle risorse in cache</b><p>Ogni volta che il webmaster aggiornerà un articolo o una pagina, il plugin installato in Joomla! si occuperà di eliminare la vecchia risorsa presente in cache, per evitare che gli utenti visualizzino un contenuto vecchio.</p><p>Contestualmente verrà anche eliminata la cache della homepage, per aggiornare gli eventuali ultimi articoli disponibili nella stessa.</p><b>Cancellazione delle risorse in cache</b><p>Considerata la funzionalità di aggiornamento e rimozione automatica delle risorse, non sarà necessario cancellare forzatamente la cache per alcun motivo. Inoltre la cancellazione totale della cache è un’azione sconsigliata, in quanto eliminerebbe dalla stessa tutte le risorse (pagine, articoli, ecc) che sono state immagazzinate in precedenza poiché molto visitate.</p><p>Su siti con moltissimi contenuti l’operazione di cancellazione totale della cache potrebbe causare inoltre un rallentamento importante, causato della necessità da parte del sito in Joomla! di rigenerare nuovamente da zero tutte le pagine o articoli richieste dagli utenti. </p><h3>COSA NON VIENE INSERITO IN CACHE</h3><p>Per rendere efficiente il sistema di cache Varnish, ci sono alcune risorse e chiamate HTTP specifiche che non verranno mai inserite in cache, ecco quali:</p><ul style=\"list-style: disc;padding-inline-start: 40px;\"><li>Qualsiasi pagina, articolo/risorsa visitato da un utente loggato.</li><li>Qualsiasi pagina, articolo/risorsa in cui viene settato un header no-cache e similari.</li><li>Tutte le chiamate dirette al backend di Joomla!.</li><li> Tutte le chiamate eseguite per inserimento dati (form di registrazione, contatti, commenti e così via.)</li></ul><h3>COME VERIFICARE CHE LA CACHE VARNISH SIA FUNZIONANTE</h3><p>Il sistema di cache Varnish setta degli header specifici nel caso la risorsa (link) richiamata sia presente o meno in cache. Per verificare se il sito web stia sfruttando la cache Varnish è quindi necessario verificare la presenza degli header specifici di Varnish.</p><p>Aprire gli strumenti per sviluppatori in base al browser utilizzato:</p><p>Firefox tramite il menù:</p><p> strumenti -> sviluppo web -> Attiva strumenti.</p><p>Chrome tramite il menù: Visualizza -> opzioni per sviluppatori -> strumenti per sviluppatori</p><p>A questo punto si apriranno gli strumenti per sviluppatori:</p><ul style=\"list-style: disc;padding-inline-start: 40px;\"><li>selezionare la scheda “Rete” oppure “Network”</li><li>selezionare la sotto-scheda “HTML” in Firefox oppure “Doc” in Chrome</li><li>ricaricare il sito web eseguendo un refresh della pagina</li><li>cliccare sulla riga relativa al nome dominio identificato con stato 200</li></ul><p>Nella colonna di destra si apriranno gli Header di risposta, l’ultimo header sarà quello relativo a Varnish:</p><p><b>X-VC-Cache: HIT</b>= la risorsa, quindi la pagina richiamata, è presente in cache ed è stata restituita da Varnish. Significa che il sistema di cache sta funzionando correttamente.</p><p><b>X-VC-Cache: MISS</b>= la risorsa, quindi la pagina richiamata, NON è presente in cache ed è stata generata dall’applicazione WordPress. Significa che il sistema di cache è stato istruito dagli header dell’applicazione oppure da regole personalizzate, a non restituire il contenuto presente in cache al visitatore.</p><h3>ATTIVAZIONE DEL SISTEMA DI CACHE VARNISH DAL WEBPANEL</h3><p>Dal WebPanel Ergonet sarà possibile impostare alcune configurazioni aggiuntive per Varnish:</p><b>Validità della cache</b><br>Parametro consigliato: <i>1 settimana</i><p>È il tempo di conservazione di una determinata risorsa in cache. Dopo questa tempistica impostata dall’utente, le risorse presenti nella cache di Varnish che avranno raggiunto tale periodo di conservazione, verranno eliminate.</p><p>Ricorda che una risorsa (ad esempio una pagina o un articolo) se modificata o aggiornata, verrà eliminata dalla cache di default, senza considerare il suo tempo di validità e senza necessità di cancellare tutta la cache. Ogni qualvolta aggiornerai una pagina o un articolo, anche la cache della homepage verrà invalidata.</p><b>Forza cache</b><br>Parametro consigliato: <i>OFF</i><p>Alcuni plugin o temi forzano gli header Cache Control in un formato che non permette a Varnish di inserire una risorsa in cache. È sempre preferibile non forzare questa direttiva, in quanto si prevede che gli header vengano correttamente settati dagli sviluppatori delle applicazioni, template ed estensioni.<br>Se attivata, è necessario verificare con accuratezza che non si presentino anomalie sul sito web.</p><b>Memoria dedicata (opzione disponibile solo su Cloud Hosting dedicati)</b><br>Parametro consigliato: <i>128MB</i><p>È la quantità di memoria RAM dedicata alla cache Varnish e 128MB è una quantità sufficiente per la maggior parte dei siti web. Per portali o ecommerce con molti contenuti o prodotti, è possibile impostare la cache a 256MB oppure a 512MB.<br>Tieni presente che più memoria RAM dedicherai a Varnish, meno ne rimarrà a disposizione per tutti gli altri siti web ospitati sullo stesso server cloud e per il sistema operativo. Aumenta questo parametro solo se hai sufficiente memoria RAM a disposizione.</p><b>Termini da escludere</b><p>Sono i termini e vocaboli eventualmente presenti nelle URL che, se presenti, fanno sì che Varnish non inserisca in cache quella specifica risorsa. Sono presenti già alcuni termini di default, ma l’elenco può essere arricchito all’occorrenza dall’utente.</p>"; 60 60 } 61 61
Note: See TracChangeset
for help on using the changeset viewer.