Skip to content

Instantly share code, notes, and snippets.

jlazic /
Created May 21, 2016 18:49
Add HIT/MISS info to headers with Django cache middleware
from django.views.decorators.cache import decorator_from_middleware_with_args
from django.middleware.cache import CacheMiddleware
class LocalCacheMiddleware(CacheMiddleware):
def process_request(self, request):
response = super(LocalCacheMiddleware, self).process_request(request)
# Add X-Cache: HIT header if response is returned from cache
if response:
response['X-Cache'] = 'HIT'
jlazic /
Created March 9, 2015 20:02
Split monolithic HAProxy configuration
#Requirements: etckeeper, diffcolor
#This script concatenates multiple files of haproxy configuration into
#one file, and than checks if monolithic config contains errors. If everything is
#OK with new config script will write new config to $CURRENTCFG and reload haproxy
#Also, script will commit changes to etckeeper, if you don't use etckeeper you
#should start using it.
#Script assumes following directory structure:
jlazic / Get-HAProxyStats.ps1
Last active May 16, 2024 08:51
Monitor HAProxy with PRTG
# Monitoring HAProxy via CSV stats
# For detailed instructions visit
# Josip Lazic
$templates =@{