Project

General

Profile

CSS style sheet cache

Added by Vincenzo Romano over 5 years ago

From time to time, if I edit a style sheet file, the new version doesn't get loaded and the cached one is used instead.

I can clearly see that with the browser debugging tools.

I am on Chromium "Version 70.0.3538.77 (Official Build)".

Closing all the browser processes doesn't help.

Is there a way to avoid this like a content="no-cache" predicate?


Replies (9)

RE: CSS style sheet cache - Added by Vincenzo Romano over 5 years ago

I need a logout to clean the cache!

I think this needs some support in Wt in order to work properly.

RE: CSS style sheet cache - Added by Dave Soane over 5 years ago

Have you tried reloading the page with Ctrl-F5 or Shf-F5? These seem to work inconsistently with Chrome (as with a few other things on Chrome), but one or the other should reload the page and refresh the CSS too.

RE: CSS style sheet cache - Added by Vincenzo Romano over 5 years ago

Sure, I did several reloads with no success, but with the "usual" F5.

Your hint seems to work perfectly and is also documented ! (Web page shortcuts).

Thanks.

Maybe I am wrong, but there seems to be no explicit CSS aging policy within the HTML and HTTP standards. Didn't it?

RE: CSS style sheet cache - Added by Roel Standaert over 5 years ago

There are general HTTP headers that control caching. wthttp sets the expiration of static resources to about a month. We don't currently have a way to configure that, since the static file serving aspect of wthttp is deliberately kept quite basic, since Wt is a web application framework, not a web server. If you want more control over things like that I would recommend putting wthttp behind a proxy, and using a web server like nginx for static resources.

While developing, you can indeed force refresh.

RE: CSS style sheet cache - Added by lm at over 5 years ago

In Chromium, you can also long-click the reload button to the left of the address bar and select one of three options.

RE: CSS style sheet cache - Added by Vincenzo Romano over 5 years ago

One month is a very long run that would affect any CSS upgrade deployment.

I'd put a programmable value or something shorter.

Proper file timestamp handling would be much better.

RE: CSS style sheet cache - Added by Roel Standaert over 5 years ago

Making the expiration time configurable could be considered (and fairly simple to implement). Could you make an issue for that?

It's generally not easy to determine where we should place the cut-off point when it comes to web server functionality.

RE: CSS style sheet cache - Added by Ockert van Schalkwyk over 4 years ago

Hi

A possible workaround

...
#include<sys/time.h>
...
    ...
    struct timeval tp;
    gettimeofday(&tp,NULL);
    long int ms=tp.tv_sec*1000+tp.tv_usec/1000;
    ...
    app->useStyleSheet("resources/themes/bootswatch/slate/bootstrap.css?mycachebust="+std::to_string(ms));
    ...

RE: CSS style sheet cache - Added by Ockert van Schalkwyk over 4 years ago

Ockert van Schalkwyk wrote:

Hi

A possible workaround

[...]

This should avoid caching on every single load, you can % the ms value to adjust the period

    (1-9/9)