diff --git a/magick/cache.c b/magick/cache.c
index 5c2c20a..0513355 100644
--- a/magick/cache.c
+++ b/magick/cache.c
@@ -784,9 +784,9 @@
   ssize_t
     count;
 
+  cache_info->timestamp=time(0);
 #if !defined(MAGICKCORE_HAVE_PREAD)
   LockSemaphoreInfo(cache_info->disk_semaphore);
-  cache_info->timestamp=time(0);
   if (MagickSeek(cache_info->file,offset,SEEK_SET) < 0)
     {
       UnlockSemaphoreInfo(cache_info->disk_semaphore);
@@ -828,9 +828,9 @@
   ssize_t
     count;
 
+  cache_info->timestamp=time(0);
 #if !defined(MAGICKCORE_HAVE_PWRITE)
   LockSemaphoreInfo(cache_info->disk_semaphore);
-  cache_info->timestamp=time(0);
   if (MagickSeek(cache_info->file,offset,SEEK_SET) < 0)
     {
       UnlockSemaphoreInfo(cache_info->disk_semaphore);