Quality Criterias      Speed of Web      Contact Us      
Pushing New File Version On some browsers, the normal reloading using F5 key is not enough to force loading of latest file version. Google Chrome is notorious of using so called "Hard Refresh", which needs Shift+F5 key kombination on user side. How to Embed Google Calendar Let's see how to configure and embed Google Calendar to your website to make events visible to every visitor, who has access to your site (or intranet) Pushing New File Version without Hard Reload
fastest

websites

in Birmingham

Pushing New File Version without Hard Reload

On some browsers, the normal reloading using F5 key is not enough to force loading of latest file version. Google Chrome is notorious of using so called "Hard Refresh", which needs Shift+F5 key kombination on user side.

Pushing New File Version without Hard Reload

The problems will most likely happen, when the user is not aware the need of loading files from fresh with "Hard Refresh" or the users are not aware about differences between "soft" and "hard" refresh versions at all.

 

Headers on .htaccess

The first obvious solution would be using header information on all files by particular type, defined in .htaccess on server side:

 

<IfModule mod_headers.c>
 <FilesMatch ".(json|pdf|swf|bmp|GIF|JPEG|JPG|PNG|gif|jpeg|jpg|png|svg|tiff|ico|flv|js|php)$">
  ExpiresActive On
  ExpiresDefault "access plus 1 week"
  ExpiresByType application/pdf "access plus 12 hours"
  Header append Cache-Control "public"
 </FilesMatch>
</IfModule>

 

All other defined file types have expiration time 1 week, but "application/pdf" has it set shorter, only 12 hours.

 

However, it seems defining some particular file types, for example .pdf separately, may not work very well. At least during testing, the Google Chrome still displayed the older version of uploaded file.

 

Using Versioning on File Name

If there is the imminent need for serving newest version of file to the user, one solution is to modify the ending of file name by adding version number.

 

<a href="/s2/760_643_73_Agenda_of_Seminar.pdf?version=1.2" title="Download File">

<img src="js/icons/pdf.gif"> Agenda of Seminar (.pdf 0,4Mb)

</a>

 

Adding different version number to the end of file as ?version=1.2 seems to work and forces Google Chrome to reload new file version every time, when version number is changed. Very important on that is, that there is no need on user side to use reloading (any combination) any more.

 

More Automated Version

If the link to the file is fully edited on content management system, described method may be used. However, it may be not very convinient to change file fersion by hand each time, the new file is uploaded. It may be also more difficult, when link to the file is created dynamically in content management system or the users are not aware of need to modify the version number.

 

One possible solution would be using automatic time stamp on php script using integrated function date() with format ddhhmmss as described on php manual.

 

 d
  Day of the month, 2 digits with leading zeros   01 to 31
 H 
  24-hour format of an hour with leading zeros  00 through 23 
 i  Minutes with leading zeros  00 to 59
 s  Seconds, with leading zeros  00 through 59

 

in this way there is needed just to add date('dHis') to the end of file

 

$original_filename = '34_file.pdf';
echo "<a href='$original_filename?version=".date("dHis")."'>
Download the file
</a>";

 

It prints current time to the end of each time, when page is reloaded and browser loads the file again on every pageview. However, this is against of real purpose of buffering static file types as .pdf is.

 

More Optimized Way

To avoid loading file again each time, you may store last update time to database and then print new version number based on that to the end of file. Then the link to the resource differs only, when there is new uploaded version of particular file.

 

$original_filename = '34_file.pdf';
$original_timestamp = $sql[file_saving_date];
echo "<a href='$original_filename?version=".date("dHis", $original_timestamp)."'>
Download the file
</a>";

In this way the old name may be in buffer as long as there is no new version uploaded to the website throught content management system.

 

Why there is Hard Refresh Anyway?

It seems, that Google would like to have more diversification on dynamic and static resources for their indexing systems. For example, those picture files and documents, which are remaining same for very long time, downloading the file each time is waste of resources, when the file is essentially same all the time.

 

Difersifying "Refresh" and "Hard Refresh" makes more clear how dynamic and static resources are treated by Google and gives hint to serve those files, which actually change in more "dynamic" fashion, so they will be indexed and displayed from updated source.

Read also these articles
How fast is your site? Check here.
Ask a Quote for website design.

Fast Websites
Nobody likes slow website. For building fast web, you need solid and reliable website platform. Important is to host site to fast UK Web hosting server.

Web Hosting
We tested many UK Web Hosts and measured error rate and speed of web hosting servers. For reliable results, see UK web hosting firms we suggest.

Disclosure
All UK Web Hosting companies are independent firms, with own terms and conditions as well as privacy policies. Some UK Web Hosts stipend us.

Ask a Quote
Ara Website Design Ltd., 11477099,
Fastest Websites in Birmingham
For Website Design, Ask a Quote or
send us e-mail.

Web Solutions araweb.co.uk

Pushing New File Version

The problems will most likely happen, when the user is not aware the need of loading files from fresh with "Hard Refresh" or the users are not aware about differences between "soft" and "hard" refresh versions at all   Headers on On some browsers, the normal reloading using F5 key is not enough to force loading of latest file version. Google Chrome is notorious of using so called "Hard Refresh", which needs Shift+F5 key kombination on user side.

Pushing New File Version without Hard Reload

www.araweb.co.uk © 2017 Ara Website Design Ltd. » Maker of Fast Websites