I'm running Grav CMS on a Linode Ubuntu 16.04 server where PHP7 (php-fpm + nginx) returns cached results when listing directory contents. I first encountered the problem with FilesystemIterator, but it isn't limited to that class - the same problem appears when I use scandir.
Basically what happens is that any time I sync new content to the server, whether I use rsync or FTP, PHP will return the old contents of a particular folder.I've tried calling clearstatcache, but it didn't help – even if I called it from the appropriate PHP file, just before I scanned the directory.
touch'ing the files to update their mtime doesn't help either. Restarting the php-fpm service does work, however.
Is it possible that PHP caches the contents of the directory in some other way? Could it be the file system that is fooling PHP somehow?
There is but it's not something I would use in production.
Run sync first: $ sync
This command writes any cache data that hasn't been written to the disk out to the disk.
Free pagecache:echo 1 > /proc/sys/vm/drop_caches
Free dentries and inodes: echo 2 > /proc/sys/vm/drop_caches
Free pagecache, dentries and inodes: echo 3 > /proc/sys/vm/drop_caches
That being said I would also take a look at realpath_cache.
It turns out the problem I was having wasn't due to the OS or PHP, but to the Grav CMS itself – specifically how it caches page objects. It doesn't invalidate cached pages if all that had changed was the associated media files. Turning off the global cache setting for Grav helped this issue, but I've also opened an issue on the Grav repo to see if this is inteded behaviour or not.
Related
I'm using valet+ and Wordpress 5.9 on a local environment.
I have a simple task of updating some new terms of my payment module.
They are located under wp-content/plugins/my-plugin/languages/my-plugin.* where * represents .pot and -pt_BR.mo and -pt_BR.po files.
Some old terms are still working in the admin, even if I remove everything in this folder and refresh the page. The new terms are not being translated at all.
I already tried to restart valet (php, nginx, etc), and also used wp-cli cache flush command.
Am I missing something here? Or is there any other place to look for translation cache that I am leaving behind?
It turned out that wordpress was loading another file located under wpcontent/languages/plugin/my-plugin.*.
Removing those files solved the problem. No cache cleaning or restart was needed on local environment.
I've tried to install Magento 2 locally using XAMPP. This works fine, except for the fact that when I alter my CSS, HTML or JS, XAMPP won't get the updated files. It just takes the file I initially created with it's content, but not the updated version.
I think this has something to do with caching of Apache itself? I read something about disable cache using .htaccess (http://httpd.apache.org/docs/2.0/mod/mod_cache.html) but I can't figure out how to implement this.
Anyone knows how I can fix this?
Flushing cache doesn't work. Deploy static content may work, but I don't want to do that every time I make one minor change in the CSS (when I worked remotely, I did not have to do that either)
I think this problem is not Magento related, but rather something with XAMPP (probably Apache).
I have developer mode enabled.
Press Ctrl-F5 to hard refresh the page (to not use Browser's cache).
If you still see the previous pages or changes, then Apache has
mod_cache caching them, or PHP has its opcode cache settings set to
not refresh changes for X amount of time.
Taken from Xampp and Ampps don't reload files when changed
If mod_cache that is causing the problem then this might help you implement the fix How to disable cache of Apache?
This is not a caching issue, but rather the deploy mode you're using.
You are probably in default mode, in which case you will have to deploy static content every time, however you can switch to developer mode.
https://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-mode.html
This will stop magento having the need to generate the static content as it's done on the fly via the use of symlinks etc.
bin/magento deploy:mode:set developer
Or alternatively you can manually set this inside
app/etc/env.php
If developer mode isn't working it's more than likely down to permissions etc
Delete all files inside pub/static apart from the htaccess file, and make sure it's writable
In developer mode, M2 does not generate static files. It should create symlinks to them from the various modules. If you however have ran setup:static-content:deploy and have those files in place, it won't update them. Try to delete only those files inside pub/static folder on which you've worked and see if Magento links to them. If you delete all contents of pub/static/ folder, pages will take very long to load in browser.
Last week, I tried to deploy a simple symfony app on azure.
I choose the plan app service B2 (2cores / 3.5Go RAM).
PHP Version : 5.6.
First it took forever to complete the composer install. (I tried to go on S3, it was a little faster but not very different).
So I tried to optimize the php config, opcache, realpath_cache_size...etc (xdebug already disabled).
I even tried to enable wincache, but with no real improvment.
So now my app is deployed, but it is too slow to be usable.
A simple php app/console (in dev mode) takes ~23secondes.
It seems to recreate the cache everytime. On my local unix environnment (similar specs), it takes 6seconds when the cache is cold and 500ms when the dev cache is warm.
I think that the main problem is a filesystem issue, because to remove the dev cache folder it takes 16 seconds.
On my local unix environnment, similar specs, it takes ~200ms to remove the same folder.
Like I said I tried S3 Plan with a small improvment but not enough to explain this slowness.
One thing weird, it's that if I rerun the command php app/console just after it finished, the command takes 5seconds to run (much better). But If rerun it 5seconds after it finished, it takes 23seconds.
I already tried these solutions (even if the environnment is different) :
https://stackoverflow.com/a/17021255/6309878
Update : I tried to set the symfony app/cache folder to the local filesystem D:\local\cache, but no improvment, it may be worst.
Please try below steps and let me know if it improves the performance -
1) In the wwwroot directory of your site, create a .user.ini file (if it doesn’t already exist) and add “wincache.fcenabled=0”. This will disable Wincache.
2) Go to Azure Portal and go to the Application Settings for your app. In the App Settings section, add “WEBSITES_DYNAMIC_CACHE” with a value of 1.
3) Restart the site.
Since about three weeks changes on .phtml files have no effect on our productive magento installation. Therefore the same changes take effect on our test installation which is essentially a copy of it. Changes are made on the test installation. Thereby I'm following the Template Path Hints. Of course we are using our own template like: /app/design/frontend/venedor/mod/ We don't modify core, base or default-files. After everything looks fine the changes are transfered to production. Changes are uploaded successfully and downloading again shows the changes. Have doublechecked the Template Path Hints in production, too. Cache has been cleared about a thousand times.
The same with .php files. But changes in .csv files in /app/design/frontend/venedor/mod/locale/ take effect.
We are running Magento CE 1.9.2.1 on:
Linux 2.6.32-openvz-042stab084.17-amd64 (no root-access, no more information)
nginx 1.9.3
PHP 5.3.27 +PHP-FPM
Google PageSpeed is available but disabled
I have absolutely no clue about this behavior... Maybe some kind of caching effect of nginx or PHP-FPM? Any idea or what kind of information I should add?
Try appending ?abc=def to the url to see if the page changes. If it does then you know it's caching issue. Do you have Varnish cache on your server?
I'm using LAMP with CodeIgniter for one of my projects; version controlled by SVN. Every time I execute svn export file:///svnrepo/project/trunk/www . --force when in the www directory and then reload the web page, it goes blank.
The website only shows up after I do a service httpd restart (Using CentOS 5).
I want to be able to execute the svn export using a Phing build script in the future and I don't want to have to get root privileges and restart apache every time when I do a build.
Is what I'm experience a common problem? How do I solve it without restarting apache?
Edit:
It seems someone has had this problem before: http://codeigniter.com/forums/viewthread/181642/
Ok I got it.SVN maintains a files last modified time which throws off the APC cache. So to solve it we update the last modified time of all the files after we run an SVN export. Here is my final script:
#!/bin/sh
svn export --force file:///home/steve/repo/exmaple/trunk \
/home/steve/public_html/example.com/public/
find /home/steve/public_html/exmaple.com/public | xargs touch
You can find more details here.
An alternative solution would be to set apc.stat=0 (reference) in the apc.ini, and then use apc_clear_cache() (reference) to force the removal of the opcode cache.
What's awesome about this solution is that when apc.stat is set to 0, it disables the check on each request to determine if the file has been modified. This results in a huge performance boost.
Additionally, using apc_clear_cache() to clear the APC cache tends to result in a cleaner build. I've run into wonky race conditions where certain files will get built out that have dependencies on others that have not yet been built out. This results in a spat of FATAL errors. The only caveat here is that apc_clear_cache() needs to be run via apache, so you'll need to implement a wgetor something similar for this.