Project

General

Profile

Actions

Feature #7251

closed

JavaScript & CSS are cached too aggressively by browsers, add URL fingerprint or other cache control mechanism

Added by Jim Pingle about 7 years ago. Updated about 7 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
Web Interface
Target version:
Start date:
02/10/2017
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Release Notes:

Description

JavaScript and CSS are cached too aggressively by browsers, so when any significant change happens, users must manually clear their browser cache or GUI behavior is unpredictable/erratic.

There are a few ways to combat this, such as URL fingerprinting (e.g. "blah.js?12345") or web server header changes. Adding one or more of these methods will ensure users do not have to take manual action when we make changes to JavaScript or CSS, and if we add a method that uses a file hash to identify the file, it could be fully automated (or nearly so).

More suggestions here: https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#invalidating-and-updating-cached-responses

Actions #1

Updated by Kill Bill about 7 years ago

There is the same problem with CSS.

Actions #2

Updated by Jim Pingle about 7 years ago

  • Subject changed from JavaScript is cached too aggressively by browsers, add URL fingerprint or other cache control mechanism to JavaScript & CSS are cached too aggressively by browsers, add URL fingerprint or other cache control mechanism
  • Description updated (diff)

I knew I was forgetting something!

Updated subject/descr

Thanks

Actions #3

Updated by Anonymous about 7 years ago

A simple way to deal with this might be to prevent caching on the login page. That way all the CSS and JS is re-loaded once but can be cached for the rest of the session.

This is also a nice solution:

<link rel="stylesheet" href="mycss.css?v=<?php echo filemtime('mycss.css') ?>"/>

I will do some testing.

Actions #4

Updated by Anonymous about 7 years ago

The above solution seems to work as expected. I have added it to head.inc and foot.inc

Actions #5

Updated by Anonymous about 7 years ago

  • Status changed from New to Feedback
Actions #6

Updated by Anonymous about 7 years ago

  • % Done changed from 0 to 100
Actions #7

Updated by Jim Pingle about 7 years ago

  • Status changed from Feedback to Resolved

Seems to work fine. I upgraded a VM that was on a snapshot from before all of the GET/POST conversion and when upgraded and synced to include this code, the client browser picked up the new javascript without any manual intervention.

Thanks!

Actions #8

Updated by Kill Bill about 7 years ago

Works here as well. Yay, finally!

Actions

Also available in: Atom PDF