@@ -227,16 +227,47 @@ event.
227
227
#### Cache tag invalidation within the Contao back end
228
228
229
229
When working with DCAs in the Contao back end you don't have to register callbacks at various places to make sure certain
230
- tags are being invalidated. This is because Contao invalidates a certain set of tags whenever a back end entry is created,
231
- updated or deleted. The tags are as follows:
230
+ tags are being invalidated. This is because Contao invalidates a certain set of tags whenever a back end entry is created,
231
+ updated or deleted.
232
232
233
- * ` contao.db.<table-name> `
234
- * ` contao.db.<table-name>.<id> `
235
- * ` contao.db.<parent-table-name> ` (only if there is a parent table defined)
236
- * ` contao.db.<parent-table-name>.<pid> ` (only if there is a parent record)
233
+ The tags are as follows:
234
+
235
+ * ` contao.db.<table-name>.<id> ` (The record itself)
236
+ * ` contao.db.<table-name> ` (Only if the DCA has no parent table defined)
237
+
238
+ If the DCA has a ** parent table** , Contao recursively iterates upwards the table hierarchy and invalidates the following
239
+ tags as well:
240
+
241
+ * ` contao.db.<parent-table-name> ` (Only for the topmost parent table)
242
+ * ` contao.db.<parent-table-name>.<pid> `
243
+
244
+ If the DCA has one or many ** child tables** , Contao recursively iterates downwards the table hierachy and invalidates the
245
+ following tags as well:
246
+
247
+ * ` contao.db.<child-table-name>.<cid> `
248
+
249
+ ##### Example: Edit a news article
250
+
251
+ Imagine you have edited a news article with ID 42. Contao will now automatically send an invalidation request to the
252
+ reverse proxy to invalidate all responses associated with the following tags:
253
+
254
+ * ` contao.db.tl_news_archive ` (The topmost parent table)
255
+ * ` contao.db.tl_news_archive.1 ` (The parent record)
256
+ * ` contao.db.tl_news.42 ` (The record itself)
257
+ * ` contao.db.tl_content.420 ` (The first child record)
258
+ * ` contao.db.tl_content.421 ` (The second child record)
259
+
260
+ Only the topmost parent table tag will be invalidated, i.e. ` contao.db.tl_news_archive ` , but not ` contao.db.tl_news `
261
+ or ` contao.db.tl_content ` .
262
+
263
+ ##### Example: Edit a contact record (custom DCA)
264
+
265
+ Imagine now you have your own DCA table ` tl_contact_details ` with no parent or child tables. When you edit the contact
266
+ record with ID 42, Contao will automatically invalidate the following tags:
267
+
268
+ * ` contao.db.tl_contact_details.42 ` (the contact record itself)
269
+ * ` contao.db.tl_contact_details ` (the table itself)
237
270
238
- So let's say you had a DCA table named ` tl_news ` . When you edit ID ` 42 ` , Contao would automatically send an invalidation
239
- request to the reverse proxy to invalidate all responses associated with the tags ` contao.db.tl_news ` and ` contao.db.tl_news.42 ` .
240
271
If you follow this convention and tag your responses accordingly in the front end, you don't have to do any work in the
241
272
back end at all!
242
273
0 commit comments