WeBWorK Main Forum

Minified CSS links not generated until refresh

Minified CSS links not generated until refresh

by Doug Torrance -
Number of replies: 2

I just upgraded our WeBWorK server to 2.18 and I'm running into an interesting problem.  Sometimes, when a page is loaded, the links to the CSS files give me 404 errors since they're not pointing to the minified versions with the hashes in the filenames.  For example:

<link href="/webwork2_files/themes/math4-green/bootstrap.css" rel="stylesheet">

But after refreshing (sometimes several times), I finally get the correct link, e.g.,:

<link href="/webwork2_files/themes/math4-green/bootstrap.4be740be.min.css" rel="stylesheet">

I tried clearing my browser's cache, but that didn't help.  Any thoughts?

Thanks!

In reply to Doug Torrance

Re: Minified CSS links not generated until refresh

by Glenn Rice -

You need to restart the webwork2 app.  Run "sudo systemctl restart webwork2" for this.

What is happening is that you have run "npm ci" after starting the webwork2 app initially, and changed the static-assets.json file.  Since the server has already loaded the old version of that file (or failed to load it if you hadn't run "npm ci" before starting the server), any worker that has not been restarted since the app started will not get the correct minimized file names.  When you refresh the page in the browser you might get lucky and use a worker that has been restarted, or not.  If a worker that has been restarted is used, you get the correct link.  Otherwise it falls back to the original filename without the minimized hash.

When you restart the app, all workers are restarted and the issue will be fixed.

This is expected behavior.  It is tantamount to needing to restart apache2 prior to webwork 2.18.  In fact exactly the same behavior could be observed with webwork 2.17 in this scenario.

In reply to Glenn Rice

Re: Minified CSS links not generated until refresh

by Doug Torrance -

Ah, a nice simple fix -- thank you!

I ended up needing to run "npm ci" twice.  The first time was using Ubuntu 22.04's node package, which is still at version 12, and I got syntax errors.  I ended up installing the official node 18 binaries from nodejs.org and using those, but apparently I did that after I'd started the webwork2 service and didn't think to restart it.

Thanks again!