-
Notifications
You must be signed in to change notification settings - Fork 0
/
fastly.rules_defaults.inc
87 lines (81 loc) · 3.35 KB
/
fastly.rules_defaults.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @file
* fastly.rules_defaults.inc
* Provides default rules to purge Fastly cache.
*/
/**
* Implements hook_default_rules_configuration().
*/
function fastly_default_rules_configuration() {
// Define four reaction rules. These are initially purge Fastly cache for
// listed entity page and front page when node, comment, user profile or
// taxonomy term is created, updated or deleted but the user can modify the
// values and add more URL(s) to be cleared as well as add a new rule which
// implements Purge by URL(s) action.
// 1. Reaction rule to purge Fastly cache when a comment is created,
// updated or deleted.
// Purges comment page, relevant node page, and front page.
if (module_exists('comment')) {
$configs['rules_fastly_purge_comment'] = rules_import('{ "rules_fastly_purge_comment" : {
"LABEL" : "Purge Fastly cache when a comment is created, updated or deleted.",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "fastly" ],
"REQUIRES" : [ "rules", "fastly", "comment" ],
"ON" : { "comment_update" : [], "comment_delete" : [], "comment_insert" : [] },
"DO" : [
{ "fastly_rules_action_purge_by_urls" : { "urls" : "comment\/[comment:cid]\r\nnode\/[comment:node:nid]\r\n[site:url]" } }
]
}
}');
}
// 2. Reaction rule to purge Fastly cache when a node is created,
// updated or deleted.
// Purges node page and front page.
$configs['rules_fastly_purge_node'] = rules_import('{ "rules_fastly_purge_node" : {
"LABEL" : "Purge Fastly cache when a node is created, updated or deleted.",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "fastly" ],
"REQUIRES" : [ "rules", "fastly" ],
"ON" : { "node_update" : [], "node_insert" : [], "node_delete" : [] },
"DO" : [
{ "fastly_rules_action_purge_by_urls" : { "urls" : "node\/[node:nid]\r\n\u003Cfront\u003E" } }
]
}
}');
// 3. Reaction rule to purge Fastly cache when user account is created,
// updated or deleted.
// Purges user profile page and front page.
$configs['rules_fastly_purge_user_profile'] = rules_import('{ "rules_fastly_purge_user_profile" : {
"LABEL" : "Purge Fastly cache when user profile is created, updated or deleted.",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "fastly" ],
"REQUIRES" : [ "rules", "fastly" ],
"ON" : { "user_update" : [], "user_insert" : [], "user_delete" : [] },
"DO" : [
{ "fastly_rules_action_purge_by_urls" : { "urls" : "user\/[account:uid]\r\n\u003Cfront\u003E" } }
]
}
}');
// 4. Reaction rule to purge Fastly cache
// when taxonomy term is updated or deleted.
// Purges taxonomy term page.
if (module_exists('taxonomy')) {
$configs['rules_fastly_purge_taxonomy_term'] = rules_import('{ "rules_fastly_purge_taxonomy_term" : {
"LABEL" : "Purge Fastly cache when taxonomy term is updated or deleted.",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "fastly" ],
"REQUIRES" : [ "rules", "fastly", "taxonomy" ],
"ON" : { "taxonomy_term_update" : [], "taxonomy_term_delete" : [] },
"DO" : [
{ "fastly_rules_action_purge_by_urls" : { "urls" : "taxonomy\/term\/[term:tid]\r\n[term:url]" } }
]
}
}');
}
return $configs;
}