Skip to content

Instantly share code, notes, and snippets.

View alekstrust's full-sized avatar

Javier Távara alekstrust

View GitHub Profile
@alekstrust
alekstrust / default.vcl_PREFACE.md
Created March 17, 2020 14:08 — forked from fevangelou/default.vcl_PREFACE.md
The perfect Varnish configuration for Joomla, WordPress & other CMS based websites

The perfect Varnish configuration for Joomla, WordPress & other CMS based websites

IMPORTANT: Read this before implementing one of the configuration files below (for either Varnish 3.x or 4.x+).

USE: Replace the contents of the main Varnish configuration file located in /etc/varnish/default.vcl (root server access required - obviously) with the contents of the configuration you'll use (depending on your Varnish version) from the 2 examples provided below.

IMPORTANT: The following setup assumes a 3 minute (180 sec) cache time. You can safely increase this to 5 mins for less busier sites or drop it to 1 min or even 30s for high traffic sites.

This configuration requires an HTTP Header and a user cookie to identify if a user is logged in a site, in order to bypass caching overall (see how it's done in the Joomla section). If your CMS provides a way to add these 2 requirements, then you can use this configuration to speed up your site or entire server. You can even exclude the domains you don't want to cach

@alekstrust
alekstrust / varnishlog-purge.sh
Created March 17, 2020 14:06 — forked from dnunez24/varnishlog-purge.sh
Varnish View Logged Purge Requests
varnishlog -g request -q 'ReqMethod eq "PURGE"'
-- delete any usermeta specific to the other subsites
delete from wp_usermeta where meta_key regexp '^wp_([0-9]+)_';
-- duplicate the wp_usermeta structure in a working data table,
-- but add a unique index for filtering out duplicates
create table _fix_usermeta like wp_usermeta;
-- fix to allow larger keys on InnoDB
set global innodb_large_prefix = 1;
set global innodb_file_format = BARRACUDA;
alter table _fix_usermeta ENGINE=InnoDB;
@alekstrust
alekstrust / mem.sh
Created October 3, 2016 16:34 — forked from sayem314/mem.sh
processs memory check on linux
#!/bin/bash
ps -C $1 -O rss | awk '{ count ++; sum += $2 }; END {count --; print "Number of processes =",count; print "Memory usage per process =",sum/1024/count, "MB"; print "Total memory usage =", sum/1024, "MB" ;};'