Code Monkey home page Code Monkey logo

django-varnish's Introduction

Django Varnish

Varnish is a state-of-the-art, high-performance HTTP accelerator. For more information checkout Varnish Site

Django Varnish works with Varnish server(s) to manage caching of object pages. It allows you to monitor certain models and when they are updated, Django Varnish will purge the model's absolute_url on your frontend(s). This ensures that object detail pages are served blazingly fast and are always up to date. You may also go in and manually tweak things (such as your VCL configuration) using a management command.

Setup

  1. Install the varnish python bindings
  2. Put varnishapp in your INSTALLED_APPS then set a few more settings.
  3. Add (r'^admin/varnish/', include('varnishapp.urls')), to your URLconf

Configuration

The following settings can be configured in a VARNISH_SETTINGS setting as items of a dictionary:

  • WATCHED_MODELS

    A list of installed models whose absolute_urls you want to purge from your Varnish cache upon saving. Defaults to [].

    Example: ['auth.user','profiles.profile']

  • MANAGEMENT_ADDRS

    A list of Varnish cache addresses (containing their management ports). Defaults to [].

    Example: ['server1:6082','server2:6082']

  • SECRET

    A string to be used as the shared secret that is configured on the Varnish servers. Defaults to ''

    Example: 'super-sekrit-password'

  • THREADED

    A boolean to decide whether the connection to Varnish should be done in a different thread. Defaults to False.

Complete example:

VARNISH_SETTINGS = {
    'WATCHED_MODELS': ('auth.User', 'profiles.profile'),
    'MANAGEMENT_ADDRS': ('server1:6082','server2:6082'),
    'SECRET': 'super-sekrit-password',
    'THREADED': False,
}

Management

You can view the status of your Varnish cache servers by going to /admin/varnish/ and being a superuser. Here is what it looks like in production.

Run the management command varnishmgt to blindly execute arguments to all Varnish backends. Example:

$ ./manage.py varnishmgt purge_url "/"

django-varnish's People

Watchers

 avatar  avatar  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.