Magento - APC Caching, weird basket behaviour - magento

Has anyone ever noticed any weird behaviour with regards to the shopping cart in magento when apc caching is enabled?
I have a situation where it looks as though extra items and/or different items are being added when the user adds something.
Its very strange and aparantly random but only seems to occur when we have apc enabled.

This answer touches on what might be going on:
Memcached vs APC which one should I choose?
Simply move to memcache and your troubles should be resolved.

You may want to try and clear APC's cache, both system cache and user cache.
Note that there is a difference between regular APC cache from CLI and Web based entries, and from what I've gathered you can't simply call it from CLI it has to be from a web request like so:
system('wget --spider --quiet http://localhost/apc/clear_apc_cache.php');
clear_apc_cache.php would contain:
apc_clear_cache('user');
More details:
http://php.net/manual/en/function.apc-clear-cache.php
and note the Cache type Parameter:
If cache_type is "user", the user
cache will be cleared; otherwise, the
system cache (cached files) will be
cleared.

Related

Drupal: stop auto flush caches

I have Drupal 7 site.
somehow - every time I make any change in the site- the caches flushed (all the anonymous users can see the changes).
I want that the anonymous users will be able to see the changes only after flushing the caches manually (by clicking on the "Flush all caches" button in the Performance module).
I tried a lot of thing but with no success. for example:
Use CacheExclude module
Disable it in Devel module
Use Cleaner module (disable the option in settings)
here is my performance settings:
Please try to help me with that!
Maybe you have some custom module which is doing that?
Check out this article:
https://drupal.stackexchange.com/questions/48600/how-to-delete-cache-after-updating-deleting-adding-new-content-using-hooks
The you can search modules (first check for custom made modules if any) and it they hooked node_insert function as explained in that article.
UPDATE: but by your snapshot you didn't even turn on the cache?!? How you expect it to work when it's not turned on? Turn on caching for anonymous user.
Check "Cache Pages for anonymous users" checkbox

TYPO3: what are the different kind of caches?

In the TYPO3 backend, I can clear different kinds of cache: frontend caches, general caches, system caches... Furthermore, there are also options to clear caches in the install tools.
In many cases, especially when I develop an extension, I need to clear the caches to reflect the changes I made. However, I never really know which caches I need to clear, and most of the time, I clear each one until I saw the right output when reloading the page. In other cases, when I upgrade TYPO3 for instance, I need to clear the caches from the Install tools, otherwise it looks for php files in the old installation path.
What are the different kind of caches that can be cleared? What is the difference between each of them? Which files or database items each command clears? In which case each clear caches command is necessary (i.e. when modifying which kind of file or information)?
In TYPO3 6.2 and 7:
You can see the configuration of all caches in the backend System > Configuration in the SYS.caching.cacheConfiguration section. Every cache is registered in one or more "groups": all, system, pages. The menu items reflect these groups:
"Flush frontend caches" (cacheCmd=pages): Clears frontend and page-related caches. This makes TYPO3 re-render content which is usually cached (everything except USER_INT objects)
"Flush general caches" (cacheCmd=all): Includes frontend, plus some caches registered by extensions with clearAllCache_additionalTables (i.e. news cache, realurl caches). Despite being all it does not include the system caches (and this is why it is called "general caches" and not "all caches" in the menu).
"Flush system caches" (cacheCmd=system): Clears "system-related caches", including the class loader, localization and extension configuration file caches.
Install tool "Clear all caches": This is a hardwired to "remove all typo3temp/var/Cache files", and also all MySQL cache-tables ("cf_*", i.e. Extbase Reflection). Then it goes through all registered Caches and clears them all too.
So best is to get yourself aware what parts of your code are stored in which cache so that you understand what to flush when you change something:
PHP classes in Extbase have their content parsed in so called "Reflection Cache" (i.e. the annotations) => Flush system cache.
You extension settings ext_tables.php, ext_localconf.php, TCA are cached in the cache_core => Flush system cache.
Your fluid templates are compiled into PHP code => Flush system cache.
Your PHP code might be cached by the "opcache" of your PHP. Usually opcaches are configured to check for the modification time of the file, so usually you don't need to flush any opcache after modifying PHP files. This might not be the case in some scenarios, or if there you work through symlinks of the system time is not synchronized, then you might need to flush opcache after PHP code change => Install tool clear all cache.
Your TypoScript is also cached (cache_hash) => Flush frontend caches. Note that if you change TypoScript in the backed, this will automatically flush these caches automatically.
If your change will also affect the cached output that is rendered to the frontend, you might also need to Flush frontend cache. To avoid this you might set in your TypoScript: config.no_cache = 1.
Please note that since TYPO3 8.1 the menu in the backend and the whole system has been simplified, so we only have left:
"Flush frontend caches": Clears frontend and page-related caches, like before.
"Flush all caches": Does more or less what the install tool previously did. This will thus include also all extension caches, reflection, system caches. Since it includes the "opcache flushing", also PHP file changes would be reflected here.
To ease development without caring about some of these caches, you might want to turn them individually "off".
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['cache_pages']['backend'] = NullBackend::class;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['cache_pagesection']['backend'] = NullBackend::class;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['cache_hash']['backend'] = NullBackend::class;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['extbase_object']['backend'] = NullBackend::class;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['extbase_reflection']['backend'] = NullBackend::class;
See: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/CachingFramework/Configuration/Index.html?highlight=cache#how-to-disable-specific-caches
In very general you need to clear frontend and general caches when changes made in the record (by editing) aren't reflected on page (because page is cached).
system cache additionally keeps different configurations from extensions (all these stuff from ext_tables.php, ext_localconf.php, language files, etc.) so you need to clear it when doing changes in these files... but also when injecting for an example new repository to the controllers.
TIP: there's some plugins for the browsers which displays cache clearing icon (a.k.a. Yellow Flash) in the address bar, i.e.: TYPO3 Clear Cache for Chrome
as noone mentioned the files yet:
there are a lot of temporary files which could be removed anytime, and must be removed sometimes. partially they even are included in the cache clearing from the BE.
the base folder is /typo3temp/
caching is done in /typo3temp/Cache/ which is divided in /typo3temp/Cache/Code/ and /typo3temp/Cache/Data/
here are gathered the concatenation of some php-files (e.g. ext_tables.php)
since 7LTS there is another folder which needs manual deletion sometimes: typo3temp/autoload/ where class-information is stored for autoloading. Especially if you develop new extensions this folder is not cleared automatically on each edit.

How can we stop caching in magento

In magento, there is a option is available by which we can stop caching.
my question is why cache files are created,if we disabled the cache? and my second question Is there any way by which we can prevent creation of cache files.
There are some things cached in Magento even if the cache is turned off.
Here are some examples.
the language select in admin footer: Mage_Adminhtml_Block_Page_Footer::getLanguageSelect
the admin notification config field: Mage_Adminhtml_Block_System_Config_Form_Field_Notification::_getElementHtml
admin notification last feed update: Mage_AdminNotification_Model_Feed::getLastUpdate
last cron execution: Mage_Cron_Model_Observer::generate
and specially the table schemas. this is done by ZF itself
...and there are others.
The solution for this would be to override the methods Mage_Core_Model_App::saveCache and Mage_Core_Model_App::loadCache to not save anything or not return anything when you want it disabled completely. But I don't think this is a good idea because it might affect some parts of the application.
To ensure that the cache has been completely cleared, click the Flush Magento Cache and Flush Cache Storage buttons in the upper right hand side of Cache Storage Management menu.

Cache management and Index management in magento

Why it is sometime necessary to do Cache management to disable and Index management to re-index in magento.I am new in magento so if you know then reply this kindly.
In your development environment its advised to disable the cache because you tend to make the changes in the template / layout files often so to get it reflected on the frontend / website you are advised to disable the cache in your development environment. But don't do it in PRODUCTION.
And coming to Index Management, set it as "Save on Update" mode so that each time if you make some changes to your products, categories or attributes its getting re-indexed automatically and avoids the necessity to re-index it every time manually.
Specifically, "Block" data are the html blocks that the MVC generates to present to the frontend and even in the admin sometimes. Because of the caching and also session information, you need to log out of admin and back in for some changes to appear.
Depending on site volume, there might not be a penalty for turning off caching. If I'm doing a quick styling fix, I'll disable the block cache for a couple minutes.

Clear all website cache?

Is it possible to clear all site cache? I would like to do this when the user logs out or the session expires instead of instructing the browser not to cache on each request.
As far as I know, there is no way to instruct the browser to clear all the pages it has cached for your site. The only control that you, as a website author, have over caching of a page occurs when the browser tries to access that page. You can specify that cached versions of your pages should expire at a certain time using the Expires header, but even then the browser won't actually clear the page from its cache at that time.
i certainly hope not - that would give the web site destructive powers over the client machine!
If security is your main concern here, why not use HTTPS? Browsers don't cache content received via HTTPS (or cache it only in memory).
One tricky way to mimic this would be to include the session-id as a parameter when referencing any static piece of content on the site. When the user establishes the session, the browser will recognize all the pieces of content as new due to the inclusion of this parameter. For the duration of the session the browser will used the static content in its cache. After the user logs out and logs back in again, the session-id parameter for the static contents will be different, so the browser will recognize this is as completely new content and will download everything again.
That being said... this is a hack and I wouldn't recommend pursuing it.. For what reason do you want the user's cache to be cleared after their session expires? There's probably a better solution that can fit your situation as opposed to what you are currently asking for.
If you are talking about asp.net cache objects, you can use this:
For Each elem As DictionaryEntry In Cache
Cache.Remove(elem.Key)
Next
to remove items from the cache, but that may not be the full-extent of what you are trying to accomplish.

Resources