Skip to main content
26 votes

Refresh the cache programmatically in Magento 2 at window system

Hardcoding the types is a bad idea. Instead you can use the same method used by the cache:flush and cache:clean commands. The cache manager class can also pull all the cache types for you, as done in ...
Pmclain's user avatar
  • 2,638
26 votes

Refresh the cache programmatically in Magento 2 at window system

The below code programmatically flushes cache. It worked fine for me. Case 1: Outside Magento use Magento\Framework\App\Bootstrap; include('../app/bootstrap.php'); $bootstrap = Bootstrap::create(BP, ...
Ipsita Rout's user avatar
19 votes
Accepted

Magento 2: how to create your own custom cache type?

This is below some basic structure for create custom cache type, create one module with, app/code/Vendor/Cachetype/etc/cache.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/...
Rakesh Jesadiya's user avatar
19 votes
Accepted

Magento 2.x Overcoming FPC for Prices/Private Data

Ok, for anybody else facing a similar issue, i think i've found the best way around it. As Nicholas Miller commented, my first port of call was to look into the Block Caching system. I looked into ...
JoshCarter's user avatar
14 votes

Magento 2 Full Page Cache not working

We had the same issue after enabling FPC. The following error would occur: Fatal error: Uncaught Error: Call to a member function getIdentities() on null in /vendor/magento/module-catalog/Block/...
Paul Blundell's user avatar
14 votes

Why Customer Session is not working on full page cache?

You need to use the factory method when FPC is enabled. By Factory Method : /** * @var \Magento\Customer\Model\Session */ protected $_customerSessionFactory; public function __construct( .... ...
Rohan Hapani's user avatar
  • 17.5k
11 votes
Accepted

Magento 2: how to make a module compatible with Varnish Cache?

It depends on what your module is rendering. It boils down to do not render private, customer specific data server side. The exception being on completely un-cached pages (for example the customer ...
Vinai's user avatar
  • 14k
9 votes
Accepted

Does setting a cacheable false on block invalidate full page cache for entire page?

It is true, you can see it mentioned the Dev Docs too if you want extra confirmation : To create an uncacheable page, mark any block on that page as uncacheable in the layout using cacheable="...
Ben Crook's user avatar
  • 15.7k
8 votes

Magento 2.3 - homepage redirect to 404 page not found

Enter in you database and run this : SELECT * FROM `url_rewrite` WHERE request_path=''; Delete the rows and after that do : php bin/magento setup:upgrade php bin/magento cache:flush Disable the ...
Ylgen Guxholli's user avatar
7 votes

Check if product is in wishlist

Another approach in order to retrieve wishlist or custumer related information, is to use localStorage combined with Ajax request if the localstorage is empty. Check information in your console : ...
Franck Garnier's user avatar
7 votes
Accepted

Magento2: Product page changes are reflecting immediately even if FPC is enabled

This is a feature! Magento 2 out of the box will clear correct caches on the frontend depending on cache tags. Each entity that impacts the cache will have it's own tags. Once a product is saved all ...
nikola99's user avatar
  • 518
7 votes
Accepted

Magento 2.1 Varnish Cache not Purge

Finally I fixed myself the issue. env.php 'http_cache_hosts' => array ( 0 => array ( 'host' => '127.0.0.1', 'port' => '80', ), ), default.vcl if (req.method == "PURGE") { ...
George George's user avatar
7 votes
Accepted

Edge Side Includes (ESI) in Magento 2

Magento uses ESI to isolate navigation block from other content. The main effect of ESI is separate TTL for part of the page. However, Magento uses the isolation effect of ESI in order to minimize the ...
Andrey Konosov's user avatar
7 votes
Accepted

Varnish cache cleaning problem (Purge: Method not allowed)

Are you sure you have added the varnish cache to the Magento env.php config? You can do this by manually editing env.php or with this command php bin/magento setup:config:set --http-cache-hosts=...
paj's user avatar
  • 5,924
7 votes
Accepted

Why is full page not cached in Magento 2 even if FPC is enabled?

Most common issue is a block included in all pages with cacheable = false. Maybe an extension with this declaration in default.xml. See vendor/magento/framework/View/Layout.php, function isCacheable. ...
Daniel Ifrim's user avatar
  • 3,404
7 votes
Accepted

Magento 2 - Disable Page cache for login/register page

After some research and comments of Phillipp Sander, I have concluded that cacheable="false" is to good approach to make any page exclude from full page cache. For login page, I have updated ...
Shoaib Munir's user avatar
  • 9,512
6 votes
Accepted

Magento2: Invalidate Particular Product Page Cache From Observer

You'll be surprised, but magento 2 performs "cache invalidation" after product save. Let's take a look in module-page-cache/etc/events.xml where we find ...
Alex Constantinescu's user avatar
6 votes
Accepted

Does Magento FPC treat Customer Groups differently?

Yes, M2 has the different copy of content per Customer Groups. Plugin in from Customer Module add Customer Group Id to http context that responsible for generate cache id
KAndy's user avatar
  • 20.9k
6 votes

Why Customer Session is not working on full page cache?

You can give a try to below code: 1). Using Object Manager $ObjectManager= \Magento\Framework\App\ObjectManager::getInstance(); $context = $ObjectManager->get('Magento\Framework\App\Http\Context'...
anonymous's user avatar
  • 3,752
6 votes
Accepted

Magento 2 - Page cache with hole punch

I find out hole punching criteria, I hope this would help others too. We use hole punching for private contents only, like Items in cart on header Wishlist count on header etc While we apply Full ...
Shoaib Munir's user avatar
  • 9,512
6 votes
Accepted

Magento 2 - Use Redis in Full Page Cache

I found the solution. For Backend cache on Redis use below sample command php bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=xxxxxxxxxxx --cache-backend-redis-db=0 ...
Shoaib Munir's user avatar
  • 9,512
6 votes

Magento 2 Header Sign In Sign Out Issue

Please try the following way using knockout js. you can add following code in your .phtml file, this will help you to resolve login issue while the cache is enabled <ul data-bind="scope: 'customer'...
Aasim Goriya's user avatar
  • 5,454
6 votes

Magento 2: why we use cache mechanism at a block level?

FPC By default in Magento 2 cache lifetime fo public content is set to 86400 seconds (1 day). This means all public cache content will be invalidated after this period. It is called as Time To Live (...
Lokesh Naik's user avatar
5 votes

Magento 2: Cacheable false for specific block not working

cacheable=false on a block makes whole page not cacheable. This is how it is designed, so no problem here. As for your goal - you want to render user-specific content as part of cached page. Such ...
Anton Kril's user avatar
  • 4,496
5 votes

can i use both built in cache & varnsih cache for magento2 at a time?

When you have Varnish cache enabled in Magento 2.x configuration, Page Cache is not active anymore, these are the only two options according to this line of code: https://github.com/magento/magento2/...
Ivan Chepurnyi's user avatar
5 votes

Magento 2: Varnish + Redis for Full Page Cache at the same time?

I am using Varnish + Redis for Full Page Cache at the same time. In Magento 2.3.2, after clear both cache, visit some pages, then you will find the database in Redis for page cache will not have any ...
Key Shang's user avatar
  • 3,425
5 votes
Accepted

Non-cacheable Javascript snippets using UI components?

Do I need to worry about the FPC here? Yes, if you are using dynamic contents. Should I be using a UI component for this? It depends. UI component is an extended version of knockout js MVVM pattern....
B G Kavinga's user avatar
  • 1,266
5 votes
Accepted

Difference between Session and SessionFactory in Magento 2

There are two ways of creating object: 1) Model \Magento\Customer\Model\Session 2) Factory \Magento\Customer\Model\SessionFactory If you use Model class, it will always create shared objects it ...
Prince Patel's user avatar
  • 22.8k
5 votes
Accepted

How Magento manages store-wise cache

I finally solved it by writing a plugin for the Magento\Framework\App\PageCache\Identifier class app/code/Vendor/Module/etc/frontend/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://...
Jay Ghosh's user avatar
  • 323
5 votes
Accepted

Varnish cache not clearing from magento admin

The env.php should have: 'http_cache_hosts' => array ( 0 => array ( 'host' => '127.0.0.1', 'port' => '80', ), ), It should point to Varnish which I think in ...
Danila Vershinin's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible