Prevent WordPress from sending Cache-control http header

Thanks to @chrisguitarguy’s answer, you can control the http headers sent by WordPress via the “send_headers” hook. Here is the function I added to my theme’s functions.php file, and that solved the issue with the Varnish server. function varnish_safe_http_headers() { header( ‘X-UA-Compatible: IE=edge,chrome=1’ ); session_cache_limiter(”); header(“Cache-Control: public, s-maxage=120”); if( !session_id() ) { session_start(); } } … Read more

Getting failure when using filemtime() with wp_enqueue_style

It’s because you’re retrieving it via URL, but filemtime() requires a path. Use get_stylesheet_directory() instead. That returns a path: function pro_styles() { wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() .’/child-style.css’, array(), filemtime(get_stylesheet_directory() .’/child-style.css’), ‘all’ ); } add_action( ‘wp_enqueue_scripts’, ‘pro_styles’ );

Forcing reload of editor-style.css

There is a hook for that: ‘mce_css’. It is called in _WP_Editors::editor_settings() and you get all loaded stylesheets comma separated as the first and only parameter. Now it is easy: Use the global variable $editor_styles (here are your theme’s and parent theme’s editor stylesheets stored already), add the time of the file’s last modification as … Read more

How to cache bust a child theme style.css

@dalbaeb’s comment eventually lead to insightful discussions and a feasible solution. Thanks a lot! I believe the reason my child theme CSS was loaded using ‘ver=<parent-theme-version> was because I had followed the WP Codex on child themes 1:1. My functions.php contained this: add_action(‘wp_enqueue_scripts’, ‘theme_enqueue_styles’); function theme_enqueue_styles() { wp_enqueue_style(‘parent-style’, get_template_directory_uri() . ‘/style.css’); } The code I … Read more

What is the best caching option for WordPress multi-site on non-shared hosting?

Basic answer to “what plugin” would probably be W3 Total Cache. It is one of the most functional and actively developed plugins at moment. However complete performance chain is much longer that WordPress plugin alone can handle. Web server (Apache or something else) configuration (response time, time to first byte, headers). Database (time spent processing … Read more

Caching: APC vs APCu vs OPcache

The mix up is usually because these extensions are about two unrelated technologies: opcode caching and key-value data store. For WordPress you prefereably want both. Opcode caching is really the “normal” way to run PHP (and lack of it is essentially crippled shared hosting way). Data store can *(and should) be used by WordPress object … Read more

Should I use Transient API to store HTML String, or Object?

Should I use Transient API at all here? No. In a stock WordPress install transients are stored in the wp_options table, and only cleaned up during core upgrades. Suppose you have 50,000 posts, that’s 50,000 additional rows in the options table. Obviously they’re set to autoload=no, so it’s not going to consume all your memory, … Read more

Is this Solution for Caches vs Cookies Going to Get Me in Trouble?

Your solution with comment_author_proxyhash cookie will of course technically work – all caching plugins I know doesn’t analyze hash value and will just stop delivery of cached content based on comment_author_* cookie presense. Problem here is that page caching functionality is something websites really need and often page caching is configured exactly because naked WordPress … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)