Giter Site home page Giter Site logo

sebastiaandegeus / wp-varnish Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robert388/wp-varnish

0.0 1.0 0.0 187 KB

A WordPress plugin for purging Varnish cache when content is published or edited.

Home Page: http://github.com/pkhamre/wp-varnish

PHP 80.65% Perl 13.76% JavaScript 5.59%

wp-varnish's Introduction

WordPress Varnish

  • Contributors: pkhamre, wfelipe, eitch, linickx
  • Donate link: http://github.com/pkhamre/wp-varnish
  • Tags: cache, caching, performance, varnish, purge, speed
  • Requires at least: 3.4
  • Tested up to: 3.8
  • Stable tag: 0.9.1

WordPress Varnish is a simple plugin that purges new and edited content.

Description

This plugin purges your varnish cache when content is added or edited. This includes when a new post is added, a post is updated or when a comment is posted to your blog.

To keep widgets like "Recent posts", "Recent comments" and such up to date, you should consider using ESI and include them through a text widget for arbitrary text or HTML.

Installation

This section describes how to install the plugin and get it working.

  1. Install the plugin 'WordPress Varnish' through the 'Plugins' menu in WordPress
  2. Activate the plugin through the 'Plugins' menu in WordPress

Frequently Asked Questions

Does this just work?

Yes.

But how should my varnish configuration file look like?

I have provided a simple VCL that can be used as a reference.

Does it work for Multi-Site (or WPMU)?

Yes. Activating the plugin site-wide will provide the functionality to all blogs. Configuration can be done on the blogs individually, or can be global. If you want to configure Varnish servers globally, edit wp-config.php and include these lines just before "That's all, stop editing!" message:

global $varnish_servers;
$varnish_servers = array('192.168.0.1:80:secret','192.168.0.2:80:secret');
define('VARNISH_SHOWCFG',1);

The varnish servers array will configure multiple servers for sending the purges. If VARNISH_SHOWCFG is defined, configuration will be shown to all users who access the plugin configuration page (but they can't edit it).

If VARNISH_HIDE_ADMINMENU constant is defined, configuration page will be hide from WordPress administration.

If you want to configure Varnish version globally, edit wp-config.php and include these lines just before "That's all, stop editing!" message:

global $varnish_version;
$varnish_servers = 2; // or 3 depending your server installation

My Plugins are seeing the Varnish server's IP rather than the websurfer IP

You could install Apache's mod_rpaf module: http://stderr.net/apache/rpaf/

or, in wp-config.php, near the top, put the following code:

$temp_ip = explode(',', isset($_SERVER['HTTP_X_FORWARDED_FOR'])
? $_SERVER['HTTP_X_FORWARDED_FOR'] :
(isset($_SERVER['HTTP_CLIENT_IP']) ?
$_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR']));
$remote_addr = trim($temp_ip[0]);
$_SERVER['REMOTE_ADDR'] = preg_replace('/[^0-9.:]/', '', $remote_addr );

The code takes some of the common headers and replaces the REMOTE_ADDR variable, allowing plugins that use the surfer's IP address to see the surfer's IP rather than the server's IP.

Screenshots

  1. Screenshot of the adminstration interface.

Changelog

0.9.1

  • Fix purge with WPMS Subdirectory
  • Improve purge process, always call WP function for build URL
  • Add support of any taxonomies
  • Add feature for log varnish purge requests

0.9

  • Code refactoring (PHP5, cleanup) (CAUTION: Renaming many methods !)
  • Fix admin bar actions with constant VARNISH_HIDE_ADMINMENU
  • Hide Varnish Version selector when global $varnish_version is defined !

0.8

  • Added secret handling to WPVarnishPurgeObject, Thanks Kit Westneat
  • Change WPVarnishPurgePurgeCommonObjects to WPVarnishPurgeCommonObjects, Thanks kitwestneat
  • added @ to supress Undefined offset notice
  • minor doc changes

0.7

  • Added purge when post changes from future to publish, Thanks Marcin Pietrzak
  • Added purge when theme switched, Thanks dupuis

0.6

  • Removed plugins_loaded action as it doesnt do what was expected re: Issue #12. Thank you Ben Favre, Pothi Kalimuthu and allinwonder

0.5

  • New .vcl to fix purge as per Issue #39, Thanks Ed Cooper

0.4

  • added rule to skip caching 404s in vcl
  • WordPress-Varnish UserAgent as per ticket #23
  • document use of mod_rpaf or code fix for remote IP, Ticket #36
  • clean data rather than reject to fix ticket #31
  • added plugins_loaded hook to fix ticket #12

0.3

  • Added internationalization code. Included pt_BR translation.
  • Support to Multi-Site and WPMU with global configuration.
  • Fix on URL purges for multiple domains and blogs on sub-directories.
  • Code clean up on some functions.
  • Added configuration for purging all blog, page and comments navigation.

0.2

  • Added multiple servers support and timeout configuration.

0.1

  • Initial release.

Upgrade Notice

0.8

  • Added secret handling to WPVarnishPurgeObject, Thanks Kit Westneat

0.7

  • Added purge when post changes from future to publish, Thanks Marcin Pietrzak
  • Added purge when theme switched, Thanks dupuis

0.6

  • Removed plugins_loaded action as it doesnt do what was expected re: Issue #12. Thank you Ben Favre, Pothi Kalimuthu and allinwonder

0.3

  • Varnish PURGE configuration must support regex. wp-varnish will sometimes request with regex for special purges like refreshing all blog cache and refreshing comments.

wp-varnish's People

Contributors

boyska avatar chibani avatar eitchugo avatar flynsarmy avatar gnotaras avatar herewithme avatar ijin avatar linickx avatar nicolas-grekas avatar pkhamre avatar pothi avatar rjbaker avatar robert388 avatar someguy9 avatar timosofokus avatar vilhelmk avatar wfelipe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.