Project

General

Profile

Actions

Bug #1031

closed

Termit web page does not load at first attempt

Added by Miroslav Blaško almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
13.12.2019
Due date:
% Done:

0%

Estimated time:
Spent time:

Description

User is forced to refresh the page to see it. This occurs on both dev and stage.

Actions #1

Updated by Miroslav Blaško almost 5 years ago

  • Subject changed from termit web page does not load at first attempt to Termit web page does not load at first attempt
Actions #2

Updated by Michal Med almost 5 years ago

  • Assignee set to Miroslav Blaško
Actions #3

Updated by Martin Ledvinka over 4 years ago

FWIW, I think the problem is not on the server side. I did a bit of testing around and I think it is due to browser caching. The empty page is caused by server returning 404 Not Found for requests for JS (and sometimes also CSS) bundles. Therefore, the application does not start on client and the screen remains blank.

But when I checked, it seems that the browser is asking for the wrong files. For example, I had an error when it asked for file main.32936da8.js, however, subsequent refresh yielded a request for file main.d6824134.js, which was loaded successfully.

So my theory is as follows: the browser has cached index.html, the page loads and JS bundle referenced by this cached HTML file is requested from the server. However, in the meantime, the UI has been rebuilt by Jenkins, so the file is no longer valid (the numbers in the file name are apparently some sort of hash), resulting in a 404. Refresh reloads the cached index.html and the correct JS is requested this time.

Actions #4

Updated by Martin Ledvinka over 4 years ago

I think it's confirmed, I just checked. Build #524 produced file main.32936da8.js (see the log at https://kbss.felk.cvut.cz/jenkins/view/18OPPPR/job/termitui-dev/524/console at the end), while build #525 produced file main.d6824134.js (https://kbss.felk.cvut.cz/jenkins/view/18OPPPR/job/termitui-dev/525/console). This is consistent with my theory.

Actions #5

Updated by Petr Křemen over 4 years ago

Add a message to index.html to show to the user to refresh the page.

Actions #6

Updated by Martin Ledvinka over 4 years ago

This SO answer could help to prevent caching of the index.html in client browsers for development deployments: https://stackoverflow.com/a/2068407/4929038

Actions #7

Updated by Martin Ledvinka over 4 years ago

  • Assignee changed from Miroslav Blaško to Martin Ledvinka
  • Status changed from New to In Progress

Reassigning the issue to myself, as I'm already working on it and have a potential fix which needs to be tested.

Actions #8

Updated by Martin Ledvinka over 4 years ago

  • Status changed from In Progress to Resolved

Fixed by configuring Apache to add no-cache HTTP header to requests for TermIt static resources. This should cause the browser to always check for new version of the resources (possibly not downloading it if it hasn't changed).

It looks like it works, so hopefully this shouldn't be a problem any more. Applied the same fix to stage as well.

<Directory "/var/www/termit-dev">
    Header set Cache-Control "no-cache max-age=0" 
</Directory>
Actions #9

Updated by Petr Křemen over 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF