Force web browsers to retrieve the latest version of a page from a WordPress site

I was having a bit of difficulty with a WordPress developed site recently. I had set up a members area which allowed users to retrieve messages and downloads, but users were finding that they would get a cached version of the page and would need to do a force refresh (e.g. Shift+F5 or Ctrl+Shift+R depending on your browser of choice) to get the latest version. I did not have a caching plugin installed on the site so was at a loss as to how to solve this issue.

In the end, I found a forum post on the WordPress Support site which helped me solve the issue. All that I had to do was edit the header.php file of my custom template, and add the following four lines right at the top of the file (just underneath the <?php tag):

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');

Now users will be able to see the latest messages and downloads without having to do a force refresh themselves. This is obviously at a cost of extra bandwidth, but it’s worth it so that the site acts as it should and users see up-to-date information.

Posted in Web, WordPress | Leave a comment

Change new Twitter to look more like old Twitter

Twitter have recently revamped their website and are slowly switching users to the new interface. The redesign is supposedly aimed at giving companies a greater presence on the social network, but I think the biggest difference that users will see is on the home page where their Twitter stream is displayed. The Tweets column and the dashboard column have been switched, so that the tweets now appear on the right hand side with the dashboard on the left. I assume this is aimed at giving greater prominence to sponsored trends and promoted users, but I really don’t like the new view.

The new Twitter home pageLuckily, it’s possible to switch the columns back to how it was displayed previously. All that is needed is Greasemonkey, and the installation of a user script. I found a great script created by saintjava – I’ve taken a copy of it and uploaded it to my server so that you can download it. If you have Greasemonkey installed, then clicking the download link should be enough to get the script installed. Afterwards, Twitter should now look a little bit more like it did before:

The new Twitter homepage with the Greasemonkey script installed

Posted in Development, Twitter | Leave a comment

Adding Google Tasks to the main Gmail window

As I get older, I’m having to write down things that I need to do, otherwise I’ll forget. Up until now I’ve been using post-it notes, but my desk is getting rather messy and I’m losing track of which post-it notes are more important than others! So I’ve started using Google Tasks to keep track of what needs to be done, both one-off things and monthly things like paying bills. I can then sync Google Tasks to my Android phone with Astrid.

Since Gmail’s recent redesign, you can access Tasks from a dropdown menu in the top left:

Selecting Tasks from the dropdown menuHowever, this just displays the tasks in a pop-up in the bottom right. Thankfully, there’s a way to display them in the main window, so I can keep track of tasks without having to navigate to an extra window. First, open your Mail settings by clicking on the config icon in the top right, then selecting Mail settings:

Mail settings menuThen, select the ‘Labs’ tab. You want to enable a feature called ‘Add any gadget by URL’.

Labs settings pageFinally, select the ‘Gadgets’ tab, and enter ‘http://www.google.com/ig/modules/tasks.xml’ in the text box and click Add.

Add a gadgetYou’ll now have a Tasks gadget in the Gmail sidebar – much more convenient!

Posted in Gmail, Time management | 4 Responses

Updating WordPress blog with Android app

I’ve recently started using the official WordPress for Android app, which is available for free on the Android Market. The app allows users to create new posts, moderate comments and update content all from an Android handset. The app is very good, but before using it I had to make a small change on my WordPress site.

Initially, when adding my account details into the app, I got the following error message on my phone, which reads as follows: ‘Connection Error: XMLRPC Fault: XML-RPC services are disabled on this site. An admin user can enable them at http://www.keanei.com/…/options-writing.php (code 405)’.

Connection Error popupLuckily, this error is easy to solve. Simply log into your WordPress dashboard, then from the ‘Settings’ menu choose ‘Writing’. Here, there will be an option to enable XML-RPC Remote Publishing, simply tick the box and save the settings.

Setting in WordPress dashboard that needs updating

Now you should be able to add your WordPress account to the app!

Posted in Android, WordPress | Leave a comment

Creating virtual hosts with WAMP

I use WAMP on my computer to simplify the process of installing and running Apache, PHP and MySQL. The three together effectively mimic the setup on my web host, allowing me to develop for the web with minimum effort. However, one thing that I had never done until now is to set up a virtual host. I had simply placed directories within the ‘www’ folder and used ‘localhost/websitename’ to view the pages in my web browser. This led to problems with using relative links, as using ‘/’ would take me to the ‘localhost’ directory, rather than the ‘websitename’ directory.

The solution (which I have now discovered is very simple) is to setup a virtual host. I decided to setup a virtual host called ‘keanei’ which would show the directory ‘www/keanei’.

Firstly, you need to edit WAMP’s httpd.conf file to allow virtual hosts. To do this, click on the WAMP icon in the system tray, then select Apache and click on httpd.conf:

WAMP - open httpd.conf for editingThe file will open in Notepad. Now, uncomment the line below ‘#Virtual hosts’ so that the virtual hosts configuration file is included:

WAMP - edit httpd.confNow you need to open httpd-vhosts.conf for editing. The default path for this is ‘c:\wamp\bin\apache\Apachex.x.xx\conf\extra’, although on my PC I have WAMP installed on d:. As you can see below, I’ve added two virtual hosts – one that maps ‘localhost’ to ‘d:\wamp\www’, and one that hosts ‘keanei’ to ‘d:\wamp\www\keanei.co.uk’:

WAMP - edit httpd-vhosts.confThe next step is to edit the Windows ‘hosts’ file. The usual path for this is ‘c:\windows\system32\drivers\etc’. The basic file will include an entry for ‘localhost’, but I’ve added one for ‘keanei’:

Edit Windows hosts fileFinally, restart WAMP, and the new configuration will be in place. Now I can type ‘keanei’ into my web browser and it will display the contents of ‘d:\wamp\www\keanei.co.uk’, and most importantly all relative links will now work correctly!

Posted in Development, WAMP, Web, Windows | 1 Response

Problem downloading large apps from Android Market with HTC running CyanogenMod

Thanks to the recent developments by AlphaRev X, I’ve finally been able to S-OFF and root my HTC Wildfire. This in turn means I can put custom ROMs on it, and the best available seems to be CyanogenMod, which is a customised version of Android 2.3 (Gingerbread). The Wildfire is now working better than ever, but I did come across a problem when trying to download larger apps from the Android Market, such as Google Maps or Angry Birds.

The problem here is that the Android Market uses a cache to download the .apk files. This cache is stored in /cache, but in HTC devices /cache is pretty small and is shared with other caches, such as the Dalvik cache. One method of getting around this limitation is to set up a download folder elsewhere and change /cache/download to be a symlink. Instructions on how to do this are on the CyanogenMod forum, but I’ve reproduced them below.

You’ll need a terminal emulator installed on your device (which needs root, but if you’re reading this you’ll almost certainly have root anyway). Open this up, then enter the following commands:

mkdir /mnt/sdcard/market-download-cache
su
cd /cache
mv download download.bak
ln -s /mnt/sdcard/market-download-cache download
ls -ahl .

The final line is just to check that the symlink has been set up correctly. Now larger apps should download and install without any problems at all.

Posted in Android, Development | 5 Responses

Prevent comment spam on WordPress image and attachment pages

I’ve noticed recently that I’m getting a large amount of comment spam. This isn’t unusual, but what is strange is that most of it appears on the comments under images and attachments. Whilst this makes it easier to spot spam (because I know that anything left under an image is not going to be a useful comment), it’s quite annoying and I wondered if removing the ability to leave a comment under an image would reduce the amount of spam I get. WordPress is set up so that when you click on the thumbnail for an image, it will display the full image as a post, complete with a comment box underneath, like this:

Image displayed as a post with comment box underneath

Unfortunately, there is no general option to turn off comments under images or attachments. The solution I’ve found is to override the code in attachment.php which displays the comment box. Here is how I did this:

  • My custom theme is based on the Thematic theme. The file used to generate the code to display attachments as a post is attachment.php. This file will also generate the code to display images as a post if image.php is missing (which in my case it is). So I copied attachment.php from /wp-content/themes/thematic to /wp-content/themes/mytheme
  • I opened the copied file in Notepad++ and commented out the following line:
    comments_template();
  • I uploaded this file to the webserver and now the comments box no longer appears under attachments or images.

This solution isn’t perfect – as you can see if you click on the image above, underneath it still displays some text suggesting you leave a comment. But the comment box is no longer there which is the main thing. I’ll work on updating this text in future but hopefully I’ll now see a reduction in comment spam on image posts.

Posted in Development, WordPress | 8 Responses

Disabling plugin-container.exe in Firefox 4

I’ve recently noticed that when viewing pages with Flash content in Firefox 4 (such as YouTube or any page with a Flash advert) that my PC slows to a crawl. The Windows Task Manager shows that the culprit is plugin-container.exe. The idea behind plugin-container.exe is that Firefox runs all plugins in a separate container – so that if the plugin crashes, the browser itself doesn’t crash but stays open. In theory it is a good idea but it makes my PC unusable so the only way to go is to disable it.

Thankfully it’s not too difficult to disable – type about:config into the address bar, and search for ‘dom.ipc’.Then change the value for ‘dom.ipc.plugins.enabled’ from true to false (just double clicking on it should change the value).

Setting in about:config to change

Once this is done, restart Firefox and it will no longer use plugin-container. Now web pages featuring Flash no longer slow down my PC quite as badly!

Posted in Firefox | 2 Responses

How to remove the Clean This virus

I was recently asked to help fix a friend’s laptop. Unfortunately they’d been a victim of the Clean This virus. The virus works by tricking users into thinking that it is a legitimate anti-virus product, but upon installation it continuously gives fake virus reports in an attempt to persuade you to purchase the ‘full’ product. In reality you would just lose your money.

Once the virus has been installed, you are presented with the following screen when you start up, asking you to click to do a ‘Safe Startup’:

CleanThis splash screenThere are several automated tools available to fix this, but I prefer to do it manually (some of the tools may themselves contain viruses). Here are the steps I followed to clear the virus from the machine:

  • Reboot the computer, press F8 before Windows starts and select the option to enter Windows in Safe Mode with Command Prompt only.
  • Once the command prompt appears, type ‘explorer’ and press enter:
    Windows booted into safe mode with command prompt
  • This will then bring up the normal Windows dekstop. From here, go to the Start button, then choose Run, and enter ‘regedit’ to open the Registry Editor.
  • In the Registry Editor, you need to navigate to ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon’, and look for the Shell key, which will have a value of a filepath and ‘gog.exe’. Take a note of the filepath, then delete this key.
    Registry Editor
  • Now, open Windows Explorer and navigate to the filepath noted previously. Here you should find ‘gog.exe’, which can now be deleted.
    Location of gog.exe - delete it

Finally, restart the PC normally and it should load Windows normally. Now it would be advisable to run a full virus scan, and also use something like Malwarebytes’ Anti-Malware to ensure nothing is left.

Posted in Virus, Windows | Leave a comment

Customising Outlook 2010 to work better with Gmail

I’ve recently started using Outlook 2010 to handle my various email accounts, and so far I’ve found it to be an improvement on Mozilla Thunderbird in terms of resource usage. However, there were a few things that I needed to change to make using Outlook easier for me.

First of all, Outlook would crash whenever it tried to synchronise with my Gmail account via IMAP. Despite setting it to only synchronise my Inbox, it would still take a long time and would usually fail before completion. To fix this, I’ve changed it so that Outlook only downloads headers. This has made things much quicker. To do this, first of all go to the ‘Send/Receive’ tab, select ‘Send/Receive Groups’ and then ‘Define Send/Receive Groups’:

Headers Only - step 1Then, on the next window choose ‘Edit’:

HeadersOnly - pic2Finally, select the account to change on the left, then under ‘Receive mail items’ choose the option that you’d like.

HeadersOnly - pic3The next step for me was to change the setting that deals with viewing emails in the Reading pane. My preference is for the email to be marked as read once it’s highlighted and is being viewed in the Reading pane. To do this, first of all choose the ‘File’ tab, then select ‘Options’:

PreviewPane - pic1Next, choose ‘Mail’ from the list on the left, and click on ‘Reading Pane’ under ‘Outlook panes’:

PreviewPane - pic2Finally, click the box to select ‘Mark items as read when viewed in the Reading Pane’ and choose a custom time if desired.

PreviewPane - pic3The last step (for now) was to change the view so that conversations were threaded, as they are in the Gmail web client. To do this, simply select the ‘View’ tab, then tick the box next to ‘Show as Conversations’. This will then show emails in threads if they are related.

Threaded conversations settingOne more thing I’d like to have in Outlook is the option to archive an email, but it doesn’t seem to be possible without using customised scripts to replicate the feature.

Posted in Gmail, Outlook | Leave a comment