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
23 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,558
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
17 votes

Block with Cachable=false not rendered on product view page

This issue is still reproducible on Magento 2.0.0 Stable. There is a feature in Magento 2 exception handling, which prevents rendering of broken blocks while all other blocks are still rendered. In ...
Alex Paliarush'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
13 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.3k
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
10 votes

How to disable caching of custom block on product view page?

I assume you want to disable caching of the block by PageCache module. There are two options available: Set cacheable="false" attribute in layout. But this will make the whole product page non-...
Alex Paliarush's user avatar
9 votes
Accepted

Magento 2: What Determines if a Request is "Full Page Cacheable"

Response is marked as cacheable in \Magento\PageCache\Model\Layout\LayoutPlugin::afterGenerateXml only in case if there are no blocks in the layout of current page marked with cacheable="false" ...
Alex Paliarush's user avatar
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.6k
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

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,755
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,384
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,334
6 votes
Accepted

Magento2 change response before full page cache

So, finally I have a real solution. So I was able to track down Magento2 full page cache and turned out that it does the caching as a plugin: Magento\PageCache\Model\App\FrontController\BuiltinPlugin ...
Roland Soós's user avatar
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

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
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.7k
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,724
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,334
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,334
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,394
5 votes

Magento 2 - what full page caching software should I use if I plan to use HTTPS?

I assume you're not referring to Magento 2. For Magento 1.x, you can use Turpentine to let Magento work with Varnish. Fair warning, this is by no means a "plug and play" process! Varnish does not ...
Aric Watson's user avatar
5 votes
Accepted

Magento with Turpentine + Varnish + Nginx

Yikes lots of questions here. BTW, feel free to open issues on our github as well to get help. I know lots of folks there use nginx, while I personally have little experience with it. Do I need to ...
Aric Watson'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,476
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

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