Safari uses stale copy of a file - safari

I have a javascript file which is frequently updated on the server (every hour). It is a plugin used in websites by the website's users. It is served millions time a day.
In order for users to get the latest copy I use a header with:
cache-control: public,max-age=1800,stale-while-revalidate=3600, immutable
(Safari doesn't support stale-while-revalidate so it is ignored).
When changing the file, all browsers catch up within one hour except than Safari, where small percent of users continue to use old version of the file (could be weeks old).
Seems it is caused by returning users (users which got into a website, than got back a week later).
Is there any reason why Safari is using an old version of the file though the max-age is set?

Related

How to add GET parameter to CSS filename in plugin JCH Optimize (Joomla)

I cannot find an answer to for several weeks. Perhaps my experience in development is not so great :) One site uses the JCH Optimize plugin and I noticed that after clearing the old memory (caches), the CSS and JS file links do not change, i.e. the names of these files remain old. The problem is that the browser checks the file name and if it has not changed, then the site visitors show the old version of the style file. The question itself, where in the plugin (in which code file) i can add some GET parameters ?vers = 1.1 so that for the browser it is a new file and it would update the information for users. I will be glad to hear any solutions. Thanks.
The names of the combined css and javascript files are keyed from the names of the individual files on the page. Clearing the cache will not cause the plugin to generate a different file name.
As of version 7.0.0, there is an option to generate a different cache key if you want to change the names of the combined file. Update your current version to get that capability.

Umbraco returning non-existing values

A client asked us to move their Umbraco website. We moved it to a test environment first and everything went fine. When we moved it to the staging environment, weird stuff happened.
In the Umbraco Admin area, we've got some entries with fields. These fields are empty for X number of entries. However, in the view portion of the page (for the visitors), values are printed out for each entry! The values that are printed out are the values from the production environment. However, no connection strings in the web.config point to the production environment.
When we change the value in one of the entries, the view understands it and displays the correct one - but only on that single entry! The other ones still show the values from the production environment.
We've tried uploading the site, again and again, restarted app pools, cleared client cache, different browsers.
What could be the problem?
Looks like you've figured it out, but for anyone else who finds this, when deploying an Umbraco site, as a general rule you should NOT deploy the following:
/App_Data/umbraco.config
/App_Data/TEMP/ (the whole folder)
/App_Data/cache/
/App_Data/logs/
If you do deploy some of those files, you may get odd errors with content being wrong/out of date etc.

WebService IOS design optimization

Im using a web service to populate a tableview, but the data in my web database changes very rarely, and i don't need to always download the same data.
I need to storage the data in the device, and verify if the data on the device is different than the one on the web.
What is the best practice to do that? Parse a JSON object, containing the last version and comparing to the local version and then parsing the data if its needed ?
Is there a way to automate the last version?
If you have control over the web APIs then have a separate api that returns a timestamp for the last web data change and check this. If the date is not newer than the date of last download use the local data. imho.
I personally used local storage for the same situation on iOS and it worked great.
You just need to provide an URL which responds with the last version of the data (maybe a date) and then locally in JavaScript you first check if version online is newer than your local stored one, if it is you redownload data and place it into localstorage, otherwise you just keep old data (and don't download anything at all).
Of course everything must be done through Ajax.

Recognize changes in files

my app checks a website for some files with simple NSURLConnection Method. Now I want to recognize if one of the files has changed without downloading the file and compare it.
I thought about md5 checksums but how can I do this without wasting traffic downloading the whole file.
Do you have any ideas for this?
Check the timestamp on the file. That should be easier then using md5 checksums. I don't know how your app or or server API is implemented but the idea is pretty straightforward:
On the server create an API that allows you to query when a file was last modified (keeping track of the modification timestamps should already be handled by the OS on the server)
When you download the file on your client also store the timestamp (i.e. when the server thinks the file was last modified).
When checking whether to update a file, first ask the server timestamp for the file and compare it with the one in your client app - if the server timestamp is more recent than the one on your client download the new file, otherwise do nothing.

site moved to a new server and now pdfs wont download

I had a joomla 1.5 site for a couple of years on a linux cpanel - everything was running fine. Last week we moved it to a new linux server and now we have a strange problem. The general navigation etc works fine but linking to pdfs seems to have gone "Random". For example there are 4 pdf links on this page http://www.coinstreet.org/spacehire/conferencemeetings.html - they all have different links. However, for 3 of them the same pdf is downloaded (despite the different links) and one doesn't work at all - get a 406 error.
The new install was taken by doing a straight backup of the cpanel and then a re-install. All other functionality seems to be fine.
I am at a bit of a loss - so any suggestions would be gratefully received!
PS Just noticed that I see a lot of lines like this in the error logs
[Sat Mar 31 14:50:10 2012] [error] [client 65.92.86.225] File does not exist: /data03/c9566644/public_html/406.shtml, referer: http://www.coinstreet.org/images/stories/coinstreet/JDPS%20Childcare%20Assistant.pdf
don't know if that's relevant?
UPDATE
I created a test link to fred.pdf that DIDN'T exist on the server. WHen the link is clicked rather than giving an error as expected a pdf was downloaded. TUrns out that several pdfs are missing it seems and that this same file is downloaded. When I put a fred.pdf on the server then the test link worked as expected. So, where is this "Wrong" pdf coming from...
ANother update
I have now discovered that the same problem was happening on the old server... too oh boy!
Also, the mystery pdf that downloads is actually part of one of the articles on the site, turned into a pdf on the fly. If I unpublish that article then I get just a blank pdf appear. Time to look closely at the .htaccess file me thinks... anyone else got any thoughts?
I believe you have the filename typed in wrongly!
The link you have on your site:
http://www.coinstreet.org/images/stories/coinstreet/Meeting%20Space%20User%20Special%20Requirements%20Policy3.pdf
The link I used to see the PDF successfully:
http://www.coinstreet.org/images/stories/coinstreet/Meeting%20Space%20User%20Special%20Requirements%20Policy(3).pdf
Notice the ( ) around the 3
I think you are seeing the results of two different effects here:
a) Some form of incorrect encoding when the files were uploaded - clearly the spaces and extended characters in the file name are being url encoded prior to saving. I've seen ftp programs do this and I've also seen Joomla do this periodically. I don't know if cPanel backups don't sometimes do this too. Best advice I can give is to always rename files to remove spaces(swapping for hyphens) as well as stripping brackets, ampersands and exclamation marks (bangs). Train users to do likewise to avoid these issues - and check error logs periodically to pick up on anything you miss or that changes.
b) Now with your requests for the files not matching the actual filename you would expect to see 404 errors - but sometimes you get a file, not always the right one though. My guess here is that you have the apache module that attempts to match files based on misspellings - sorry can't recall the exact name off hand. A quick search shows mod_speling (mis-spelling of spelling is deliberate) is the most likely contender.