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, ...
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 ...
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/...
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 ...
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 ...
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/...
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(
....
...
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 ...
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-...
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" ...
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="...
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 ...
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 :
...
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 ...
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") {
...
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=...
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.
...
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 ...
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 ...
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 ...
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 ...
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
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'...
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 ...
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
...
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'...
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 ...
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 ...
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 ...
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/...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
full-page-cache × 452magento2 × 188
cache × 178
varnish × 58
magento-enterprise × 49
magento-1.9 × 42
redis × 40
block-cache × 38
magento-2.1 × 19
magento2.3 × 17
holepunching × 17
blocks × 16
layout × 13
performance × 12
customer-session × 12
event-observer × 11
caching × 11
controllers × 9
cookie × 9
magento2.4 × 8
magento-1.8 × 7
module × 7
enterprise-1.13 × 7
javascript × 6
session × 6