Cached php? Updates are rendering only if logged as admin

I was asked to fix a wordpress based site and I don't get what's going on with it. The (custom) theme has a page-home.php that is the Home page. Whatever edits I make to this file, if I refresh the page logged in wp-admin (so, I'm an admin), the change is seen, but logged out (anonymous - as the site is intended to be used) it's still the old content. I did the following: downloaded all site locally, opened all …
Category: Web

Session alternative for plugins (due to caching)

I'm building a plugin that picks a random post from the database and delivers the result dynamically to the user. For certain aspects I need to know the post ID that's been randomly selected. Session data would work perfectly for this if it weren't for website caching. When a site is cached, the post that is supposed to load dynamically, based on the session data, doesn't load anything. What alternatives do I have to using $_SESSION?
Category: Web

What is the best way to cache pages on Wordpress

I have a site with many custom queries. Some take many seconds to load a page. To solve that issue, I have been using a caching plugin. The issue is, my caching plugin does not cache a page until I click it once. I'd prefer to do this entire process without a plugin if possible. If the plugin route is the best way to go, I'd love to know that too. I have an idea that this is how it …
Category: Web

How to optimize 'select found_rows()' query? Several 'high load average' alerts daily

I have 5,000 regular posts, 6,000 posts in one post type and 2,000 posts in another post type. Needless to say, that has made the wp_posts table quite large. Not to mention, I have custom taxonomies set up to mimic the post types so for every Company A entered into Company post type, there is Company A, I manually entered Company A into Company taxonomy. That way, when I do a regular post about Company A, I can effectively tag …
Category: Web

How do you avoid caching during development?

Is there a simple way to prevent all caching when testing the appearance of changes to the site? I use WP Super Cache. I can delete its cache using the option provided, delete the cache for my browser, and still some changes to CSS or widgets do not refresh. I try other work-arounds like switching browsers or computers, but there must be a more stream-lined workflow where I can ensure I'm viewing the changes I made and not some cached …
Category: Web

Website not updating - no cache plugins active!

I've a problem with my WordPress website getting updated after I make changes to its code: I'm using phpStorm with auto-save, running the website on WAMP, locally. Therefore, right after I right new code, the file in which I write the code in should be updated, and the website quickly after that. Yet the website doesn't update. I'm not using any cache plugins, and in my browser, Chrome, I disabled caching. Also, it does get updated, but only after I …
Category: Web

Performance with autoload and the options table

I am playing around with the autoload column of the options table. I didn't find much information about how the autoloaded values are used. I tried a print_r($GLOBALS) and saw that the autoloaded options are stored in $GLOBALS['wp_object_cache']->cache['options']['alloptions']. Is there another way to access those variables? Suppose I need to access an option my_option, which was set to autoload, multiple times in different templates (eg. once in header.php, once in footer.php), which method is recommended? Is it okay that I …
Category: Web

Unable leverage Browser Caching on AWS Bitnami stack (Apache) through W3TC and Cloudfront CDN

I followed many tutorial about leveraging browser caching nevertheless I couldn't configure it succesfully, in fact GTmetric (PageSpeed and YSlow) notified me many static file that don't have a cache expire header. That's my GTmetrix result (pagespeed): I tried to find the problem looking at compatibility test on W3TC and it notified me many Apache modules missed which are required for browser caching: I followed some tutorial to enable these modules but it seems they are alread enabled, in fact …
Category: Web

Some custom taxonomy child terms not showing in admin. Caching problem?

I have a problem with some custom taxonomy terms. I am using "Types" plugin for creating custom post types and custom taxonomies. I successfully created my postype and hierarchical taxonomy and strated to add content. Everything worked great until I migrated the site from the dev server(Linux) into the live server (Microsoft IIS). Right now when I add a term as a child to another term in the taxonomy, it gets hidden from the custom taxonomy terms admin panel and …
Category: Web

Improving wpdb queries with large data

My plugin will handle large amounts of data that could could result in the queries reading over 5000 items in a database query. The admin will provide a set of CSV files that get stored/organized in the database. The user will have some common results when they go to specific pages. I can predict what that query is in most cases. I wanted to store the array of results in cache so that query is faster. I looked into wp_cache_get, …
Category: Web

Disable feed cache for custom RSS feed?

I created my custom RSS feed using the following code: add_action( 'init', 'MyCustomRSS' ); function MyCustomRSS(){ add_feed( 'examplecomrss', 'MyCustomFeedCallback' ); } /* This code seeks the template for your RSS feed */ function MyCustomFeedCallback(){ get_template_part( 'rss', 'examplecomrss' ); // need to be in small case. } This works well, but I can't seem to disable the cache -- I'm developing the feed and need to see it refreshed when I make changes. I've tried the following: add_filter('wp_feed_cache_transient_lifetime', function() { return …
Category: Web

How can I prevent caching of wp_redirect?

I am working on a multisite install where one specific site needs to have access restricted to only users who are logged in AND have a specific user meta set (key="cr_access", val="Yes"). If the user is not logged in, or that meta key is not set to "Yes", then they should be redirected to the specified url. The redirect works properly, however it seems to be getting cached. If a user tries to visit a page before logging in, then …
Category: Web

Why a URL with a query is always slower than that without a query?

I find a strange thing. For a WordPress site, a URL with a query is always slower than that without a query, even no Cache plugin is installed/enabled and no CDN cache is enabled. For example: http://www.example.com/?mytest=yes will always slower than http://www.example.com/ Below are some of my test: WP Fastest Cache disabled, URL with a query https://www.fastorslow.com/app/profile/3e875ed3-d45f-54fb-93a2-17466eeb8b79 is slower than the one without a query https://www.fastorslow.com/app/profile/7ef6f16f-6b0c-5ab6-9f1e-87c0c1a6a1aa With WP Rocket enabled, https://www.fastorslow.com/app/profile/af27e983-1a38-5870-98a3-6cc19825aee1 is slower than https://www.fastorslow.com/app/profile/86d36215-0caf-51d7-b690-d3126a081376 Another server, https://www.fastorslow.com/app/profile/9273fb55-adfc-5b8c-aa93-687bc128a95d is slower …
Category: Web

No Query String vs Ignore Query String in WordPress

I use Cloudflare and there is an option of choosing Cache level. The following are the level of Caches available [check image]- I have selected Standard. Which one should I be using for better page loading? I am not a developer, so don't expect me to understand coding language.
Category: Web

Execute inline javascript in wordpress after page fully loaded

I am trying to find out the time it takes to fully load a page in wordpress using javascript.My JavaScript code is inline.I am using wp_print_scripts hook but as it prints scripts in document head i have doubt that i am not getting the time after full page load. i am not getting the correct time as body and footer content is yet to be executed/loaded.So i think i am getting the time it takes to load the head not …
Category: Web

How can I set Cache TTL for woff and woff2 font files with htaccess?

My WordPress site htaccess file currently has these entries to set cache expiry for woff and woff2 font files: <IfModule mod_expires.c> # Content type AddType application/font-woff .woff AddType application/font-woff2 .woff2 ExpiresActive on # Web fonts ExpiresByType application/font-woff "access plus 1 year" ExpiresByType application/font-woff2 "access plus 1 year" </IfModule> But I'm still getting suggestions to set cache TTL for these files in speed testing tools. Here's one example with a cache efficiency problem: https://gtmetrix.com/reports/bydik.com/ad8hZTzh/ Is there anything wrong with my htaccess …
Category: Web

Adding a URL Parameter to JPEG images in posts

To avoid image caching issues, I would like to get WordPress to reference my jpeg images with a URL parameter. I know in javascript I can do this: <img id="idSigma" src="#" class="classSigma"> <script> $(document).ready(function() { var d = new Date(); $("#idSigma").attr("src", "images/Sigma.jpeg?t=" + d.getTime()); }); </script> Is there a way I can get wordpress to do this to all of its internal links. For example, if I right click on an image in a blog post and click on open …
Category: Web

wordpress images not showing properly

Images are not visible properly in the media library after caching them from my other website. The featured image is also not being set. However the images are showing up on the front end of the website, and the path that it is being redirected is also correct. The images attached to the posts of the previous months are all showing up and i am able to set them as the featured image. attached are the screenshots of the media …
Category: Web

Timthumb isn't displaying any images. "A TimThumb error has occured

I have a Wordpress web site which is hosted on a distributed infrastructure. I have a web server(apache) and a cache server (varnish). When I load the site directly from web server everything is OK, but when I load the site from the cache, I sometimes get the following error: Timthumb isn't displaying any images. "A TimThumb error has occured I saw some answers about this problem which mainly point out to the file permissions. But I don't get any …
Category: Web

Cache Busting using htaccess Rewrite rule?

I am trying to follow this tutorial that says i can make a server to send a file like style.css if the requested file is style.15458888.css with a rewrite rule to be put inside the htaccess file. This Rule RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+).(d+).(js|css)$ $1.$3 [L] So i followed with this in the head tag: <?php $time = filemtime(get_template_directory() .'/assets/css/main.css');?> <link href="<?php echo get_template_directory_uri().'/assets/css/main.'.$time.'.css'?>" rel="stylesheet" type="text/css"> and this inside the Htaccess: # BEGIN WordPress <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.