browse by category or date

I first encountered this problem last Saturday. I made small modification to my blog’s theme, but I couldn’t see the changes. I want to change the display of posts with certain category. Here’s the change in index.php

<h1>
	<?php if (has_category('tweet')) { 
		the_title(); 
	} 
	else { ?>
		<a href="<?php the_permalink()?>" rel="bookmark" title="Permalink to: <?php the_title_attribute();?>">
			<?php the_title();?>
		</a>
	<?php } ?>
</h1>

So if the post has category ‘tweet’, the title will be just a text, not a link to single.php. But this simple change simply never appears. These are the steps I took in my quest to clear the PHP/Wordpress cache.

  1. W3 Total Cache’s Purge All caches.

    This blog is using W3 Total Cache plugin. This plugin provide 1-click to clear all the caches. Unfortunately, I still can’t see the changes after clicking the ‘Purge All Caches’ link. [ FAILED ]

  2. Restart Web Server
    One of the recommendation to clear the cache is by restarting the webserver. Since this blog is using Nginx, I run the following command.

     service nginx restart
    

    Again, this step also unable to clear the cache. [ FAILED ]

  3. Restart PHP Service
    Another recommendation is by reloading the PHP service. Since I didn’t know which service to restart, I run the following to list all services.

     service --status-all
    


    Then I restart/reload the PHP service.

     service php7.0-fpm reload
    

    Blast! This step is still unable to clear the cache [ FAILED ]

  4. Reset OpCache
    I also saw recommendation on how to clear PHP’s caching mechanism. I created flush.php in my web root.

    <?php
       opcache_reset();
    ?>
    

    Then I open the URL (https://sodeve.net/flush.php) in my browser, continued with opening this blog in a new tab. Alas! I still can’t see the changes.

  5. Desperate Actions
    Desperate because of the continuing failure, I tried some other steps like rebooting the web server

     shutdown -r now
    

    I also deactivated the W3 Total Cache plugin. All proven to be fruitless. [ FAILED ]

  6. Finally
    On my final attempt before giving up, I created info.php

    <?php
       //Delete the file after usage!!!
       phpinfo();
    ?>
    

    I open the page in my browser, then hit Ctrl+F and typed ‘cache’. After lots of F3s, I found this line:

    This could be the key! I checked the folder listed in opcache.file_cache, I found a folder with a random-generated name. I deleted that folder and Voila! My changes is now shown [ SUCCESS ]

Lesson Learned

If I make changes to WordPress blog content, I need to flush the cache using W3 Total Cache’s Purge All Caches. But if I make changes to the blog’s source code (php files), I need to delete the folder inside opcache.file_cache.

That’s all folks! I hope it helps. Cheers!

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 9 years.

No Comment

Add Your Comment