↓
 

A Pipe and a Keyboard

A sort of Linux scrapbook

  • Home
  • About
  • Software
  • List of posts

Author Archives: Richard

Post navigation

<< 1 2 … 6 7 8 9 10 11 12 … 42 43 >>

Speeding up a WordPress site

A Pipe and a Keyboard Posted on September 13, 2013 by RichardSeptember 13, 2013

One of the top considerations of any web site owner should be speed.

In these days of broadband connections, people are used to near instantaneous results, and a slow loading front page is guaranteed to lose visitors.

There are several factors which control loading time.

One is of course server response times.  There is little that can be done about that!

Then there is the core code of the site.  WordPress is WordPress and there is little or nothing you can do to change it.

There are areas though that are well within the site owner’s control.

The Theme.

The one thing I would say about themes, from the speed perspective is that the more graphic the site, the slower it tends to be.  A graphic rich theme is going to be slow, and it is worthwhile bearing this in mind when making a choice.

Plugins.

Plugins can be a site killer.  I use a plugin on my sites – Plugin Performance Profiler (P3) – which is a good indicator of which plugins are holding the site back.  Using that plugin I have managed to shave seconds off sites’ load times, by either indicating which plugins to remove or which to replace with a slicker version.  In quite a few cases I have managed to find replacement plugins that have exactly the same functionality but are faster to load.

External links.

External links within plugins or extra coding (such as advertising or analysis0 are frequently the cause of sluggish sites, as the server has to wait to connect to those sites before continuing to serve up the rest of the main site.  If your traffic analysis site is having an off day then your site will too.  

As an example, I had a plugin on this site which displayed my blogroll on the sidebar along with their latest posts and date of posting.  Before the page could load, the server had to contact each linked site in turn to retrieve information.  I ditched the plugin and reverted to standard links and shaved 32 requests and several seconds off the load time.

Images.

These are probably the biggest contributors to “gross tonnage” of any site.  Always reduce images in physical size and compression before uploading.  A photograph that is say 3,500 by 2,000 pixels may look stunning but it will weigh many megabytes.  Setting its display size may reduce the visible size but it will still weigh all those megabytes.  If you only want it to appear at say 600 x 400, then reduce it before uploading.  Also compress it as much as possible as many kilobytes can be shaved off an image that way.

Caching.

Caching can have an enormous impact on page load times.  It does so by generating static pages from the normal dynamic ones and therefore cuts way back on database requests, code requests and file loads.  There are several excellent caching plugins which can be found on the WordPress site.  While I haven’t tried all of them, the ones I have tried give facilities to allow code compression and browser caching which help greatly with load times.

A word of warning about caching plugins – I have noticed that Plugin Performance Profiler (see above) tends to give very poor responses for caching plugins.  On closer examination though, the poor response times are almost exclusively within the Admin pages of the site.  One would assume that not many outside visitors are going to reach in there?!

Posted in Blogging, Tech stuff | Leave a reply

No buttons on WordPress Media Player

A Pipe and a Keyboard Posted on August 16, 2013 by RichardSeptember 20, 2013

One of the big changes that came with WordPress 3.6 was the introduction of an embedded media player.

I have had occasion to embedd audio files in the past and I used a plugin for the purpose.  However, if I can avoid plugins then all the better, so I ran some tests with the new version.

The first trial showed the player all right, but there were no buttons.

MediaPlayer1

I tried clicking on the left-hand end of the graphic and the player worked.  However I wanted a “Play” button.

I searched the Internet and once again discovered that I wasn’t the only one with this problem  Apparently the breakdown is because of the use of the SVG mime-type, and not all sites support this.

The main solution given was to add the mime-type to the site’s .htaccess file –

AddType image/svg+xml svg svgz
AddEncoding gzip svgz

This solves the problem, but not every site owner has access to the .htaccess file, and some may just be nervous about meddling in that area.  I devised an alternative method.

The button graphic in question is stored in two formats – .SVG and .PNG so a simple tweak to the CSS file changing the file from .SVG to PNG will also work.  However, finding the references is not easy, and anyway any modification will be overwritten by any upgrade to WordPress.  The solution is to add the following to your theme’s “style.css” file –

.mejs-overlay-button {
    background:url("/wp-includes/js/mediaelement/bigplay.png") no-repeat !important;
}
.mejs-controls .mejs-button button {
    background:transparent url("/wp-includes/js/mediaelement/controls.png") no-repeat !important;
}

The “!important” directive will ensure that the code takes precedent over any WordPress CSS.

Either method will have the required result –

/audio/911.mp3
Posted in Blogging, Tech stuff | 11 Replies

Thunderbird links not working

A Pipe and a Keyboard Posted on June 17, 2013 by RichardSeptember 13, 2013

For some time now I have been having a bit of a problem with Thunderbird.  Whenever I clicked on a link within a mail, it opened a new Firefox window but defaulted to the home page.

I got tired of copying and pasting links so searched for a solution.  As usual, my search returned loads of solutions, none of which worked.  The main cure given was to force both Firefox and Thunderbird to declare themselves as the default.  No good.

The solution is (as always) simple.

In Thunderbird, open Preferences –> Advanced.  Select the General tab and click on “Config Editor..”.  You will get a warning which you accept.  This brings up the “About:config” window.

Scroll down to (or search for) “network.protocol-handler.warn-external.http”.  Right click and select “Toggle” (i.e. set the value to “True”).  Do the same for ““network.protocol-handler.warn-external.https”.

about-config
Click to enlarge

Next time you click on a link within a mail you will be asked to choose an application.  Select Firefox (default location – /usr/bin/firefox ).  Select “Remember my choice…” and the problem is solved.

Posted in Linux, Tech stuff | 2 Replies

Shell scripting and LFTP

A Pipe and a Keyboard Posted on May 11, 2013 by RichardMay 11, 2013

I have been introducing myself to Linux shell scripting.

I maintain a fair number of WordPress installations, and part of that maintenance is the task of backing them up.  The actual backups are easy as they are done by simple scripts on the servers which are called by CRON tabs.  Each server has three tabs – one to backup the database (on a nightly basis), one to backup critical files, such as uploaded files and configuration files (run once a week) and one to backup the entire site (run once a month).

While backup files on the server are all very well, they are not much use if the server collapses, so I need to transfer those backups, and this is where the need for shell scripting came in.

To retrieve the files, I initially had to fire up my FTP programme and then log into each server in turn, download the files and then delete redundant files from the server.  That proved to be an extremely tedious job and of course it had to be done every day.

My first and obvious idea was to create a simple shell script to log onto a server and FTP a file down onto the local machine.  There were two initial problems – I would have to have a script for each individual server, and there was the problem of specifying the file I wanted to download.  For various reasons I wanted to be able to specify precisely which file I wanted to download (and the actual names varied from server to server), so this involved wildcards.

My initial solution was to create an array of variables – one set for each server containing the server address, the username, the password and where the file was to be stored locally, and some variables that were specific to the day, as each backup file was time stamped.

MYDATE=$(date +”%d.%m.%y”)
REMOTEFILE=*$MYDATE.*

SERVER[0]=”domain1.com”
USER[0]=”user1″
PASSW[0]=”password1″
LOCAL[0]=”/home/sites/BlogBackups/Site1″

SERVER[1]=”domain2.com”
USER[1]=”user2″
PASSW[1]=”password2″
LOCAL[1]=”/home/sites/BlogBackups/Site2″

I then created a simple loop which cycled through the array, connecting to each server in turn, downloading the files and then deleting the files on the server.

count=0
while [[ $count -lt ${#SERVER[@]} ]]
do
ftp -v -i -n ${SERVER[$count]} <<END_OF_SESSION
user ${USER[$count]} ${PASSW[$count]}
cd webspace/www/backups
lcd ${LOCAL[$count]}
mget $REMOTEFILE
mdelete $REMOTEFILE
bye
END_OF_SESSION
(( count++ ))
done

I as quite pleased with this effort as it ran perfectly and did precisely what I intended.

Until the end of the month, that is.

On the first of the month, I ran my script and it locked up.

A little investigation found the cause – it was downloading files greater than 200Mb, but on completing the download the script just stopped, for no apparent reason.  There were no error messages, no timesouts, nothing.  I searched the Web but couldn’t find any mention of a possible cure for this.  In the end I posted a query on a couple of forums, and while they didn’t provide an answer they did suggest something else – that I try something other than FTP.

Unfortunately, for various reasons none of the suggestions worked, so I started my own search and found LFTP.

LFTP is essentially FTP with a load more bells and whistles.  It took a while to sort it out as my only reference was the Web.

The basic command line to retrieve a file from the server is

lftp -u username,password ServerURL -e “get /webspace/www/backups/remotefile”

I modified this using mget rather than get as that allowed for wildcards.  I used a loop to cycle through my array and that’s where the fun began.

First of all it started throwing up warnings left right and centre about bad certificates.

WARNING: Certificate verification: Not trusted
WARNING: Certificate verification: Expired
WARNING: Certificate verification: certificate common name doesn’t match

This was easily cured by adding a line at the bottom of /etc/lftp.conf – set ssl:verify-certificate no 

My next problem was that it would access the first server all right but would refuse to connect to any other, giving an error that there was “No Route to Host”.  It was logging in all right on Port 21, but was then trying random ports to do the actual transfer and kept cycling through them.

I cured the long wait between cycles by adding three more lines to /etc/lftp.conf –

set net:timeout 10
set net:reconnect-interval-base 5
set net:reconnect-interval-multiplier 1

While that sped things up a bit, it didn’t solve the problem!  I tried forcing Active mode over Passive but that had no effect.

The solution in the end was to add yet another line to /etc/lftp.conf –

set ftp:ssl-allow false

I ran the script, deliberately including some large files and it worked.

My final script –

count=0
while [[ $count -lt ${#SERVER[@]} ]]
do
lftp -u ${USER[$count]},${PASSW[$count]} ${SERVER[$count]} -e “mget -E /webspace/httpdocs/backups/$REMOTEFILE -O ${LOCAL[$count]}; ; exit”
(( count++ ))
done

I added in a couple of extra features – the –E flag deletes the remote file but only on successful download, and the –O flag sets the target location for the file.  I ran it against the full server load (having previously uploaded some of the large files) and it ran perfectly.

LFTP is an immensely powerful tool as it provides such commands as MIRROR which can be used to mirror a local folder with a remote one.  I can see myself using it a lot more! 

Posted in Linux, Tech stuff | Tagged Linux | Leave a reply

Thunderbird opening multiple windows

A Pipe and a Keyboard Posted on April 13, 2013 by RichardAugust 5, 2015

I have been having a small but irritating problem with Thunderbird.

I use the Nightly (Firebird) version which is currently V21, but I believe this problem is not new.

Whenever I opened Thunderbird, it insisted on opening three or more versions of itself, which meant closing several windows every time.  It started off with three windows, but over time this grew to seven which meant a tiresome session of closing windows each time.

I searched the Internet and this is not a new problem.  The answer generally given is to close the extra windows using Alt+F4 but this didn’t work for me.  It closed the windows all right, but the next time I ran Thunderbird the problem was still there.

The solution is simple.

Delete the file “session.json”.

For the uninitiated, open your file browser and ensure that “View –> Show hidden files” is selected.

Browse to home/.thunderbird (note – dot thunderbird!) and you will find “session.json” in your default profile folder.  If for any reason you have several profile folders, the active one is listed in the file “profiles.ini”.

Well, it worked for me…….

Posted in Linux, Tech stuff | 3 Replies

Post navigation

<< 1 2 … 6 7 8 9 10 11 12 … 42 43 >>

Recent Posts

  • GRUB problems
  • Tab bar broken again in Firefox 133
  • WP phpMyAdmin Session mismatch
  • When Linux slows down
  • Firefox broken again

Categories

  • Blogging
  • General
  • Linux
  • Media
  • Tech stuff
  • Writing

Blogroll

  • Head Rambles
  • Kirk M's Just Thinkin'
  • Wordpress Beginner
  • Wordpress Development

Archives

©2025 - A Pipe and a Keyboard - Weaver Xtreme Theme
↑