File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed
app/code/Magento/PageCache Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2015 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \PageCache \Model \Observer ;
7
+
8
+ class InvalidateCacheIfChanged
9
+ {
10
+ /**
11
+ * @var \Magento\Framework\App\Cache\TypeListInterface
12
+ */
13
+ protected $ typeList ;
14
+
15
+ /**
16
+ * Application config object
17
+ *
18
+ * @var \Magento\PageCache\Model\Config
19
+ */
20
+ protected $ config ;
21
+
22
+ /**
23
+ * @param \Magento\PageCache\Model\Config $config
24
+ * @param \Magento\Framework\App\Cache\TypeListInterface $typeList
25
+ */
26
+ public function __construct (
27
+ \Magento \PageCache \Model \Config $ config ,
28
+ \Magento \Framework \App \Cache \TypeListInterface $ typeList
29
+ ) {
30
+ $ this ->config = $ config ;
31
+ $ this ->typeList = $ typeList ;
32
+ }
33
+
34
+ /**
35
+ * Invalidate full page cache if content is changed
36
+ *
37
+ * @return void
38
+ */
39
+ public function execute (\Magento \Framework \Event \Observer $ observer )
40
+ {
41
+ if ($ this ->config ->getType () == \Magento \PageCache \Model \Config::BUILT_IN && $ this ->config ->isEnabled ()) {
42
+ $ object = $ observer ->getEvent ()->getObject ();
43
+ if ($ object instanceof \Magento \Framework \Object \IdentityInterface) {
44
+ if ($ object ->getIdentities ()) {
45
+ $ this ->typeList ->invalidate ('full_page ' );
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
Original file line number Diff line number Diff line change 13
13
<observer name =" invalidate_builtin" instance =" Magento\PageCache\Model\Observer\FlushCacheByTags" method =" execute" />
14
14
</event >
15
15
<event name =" clean_cache_after_reindex" >
16
- <observer name =" reindex_cache_flush" instance =" Magento\PageCache\Model\Observer\FlushCacheByTags " method =" execute" />
16
+ <observer name =" reindex_cache_flush" instance =" Magento\PageCache\Model\Observer\InvalidateCacheIfChanged " method =" execute" />
17
17
</event >
18
18
<event name =" adminhtml_cache_flush_system" >
19
19
<observer name =" flush_system_pagecache" instance =" Magento\PageCache\Model\Observer\FlushAllCache" method =" execute" />
You can’t perform that action at this time.
0 commit comments