From 302a40227754f2ab872931bc2b494a305e717ffe Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Fri, 13 Jan 2023 17:51:35 -0300 Subject: [PATCH] Avoid caching issues using last modified time Signed-off-by: RD WebDesign --- auditlog.php | 2 +- cname_records.php | 2 +- db_graph.php | 4 +-- db_lists.php | 4 +-- db_queries.php | 6 ++-- debug.php | 2 +- dns_records.php | 4 +-- gravity.php | 2 +- groups-adlists.php | 6 ++-- groups-clients.php | 8 ++--- groups-domains.php | 6 ++-- groups.php | 6 ++-- index.php | 2 +- login.php | 2 +- messages.php | 2 +- network.php | 4 +-- queries.php | 4 +-- queryads.php | 2 +- scripts/pi-hole/php/footer.php | 2 +- scripts/pi-hole/php/func.php | 13 ++++++++ scripts/pi-hole/php/header.php | 59 ++++++++++++++++------------------ settings.php | 4 +-- taillog-FTL.php | 2 +- taillog.php | 2 +- 24 files changed, 80 insertions(+), 70 deletions(-) diff --git a/auditlog.php b/auditlog.php index 1358b14e..3c311ac6 100644 --- a/auditlog.php +++ b/auditlog.php @@ -79,7 +79,7 @@ require 'scripts/pi-hole/php/header_authenticated.php'; - + - + - - + + diff --git a/db_lists.php b/db_lists.php index 25e2677a..b8e17b76 100644 --- a/db_lists.php +++ b/db_lists.php @@ -145,8 +145,8 @@ if ($boxedlayout) { - - + + - - - + + + Generate debug log - + - - + + Update - + - - - + + + - - - - + + + + - - - + + + - - - + + + - + Donate if you found this useful. - + diff --git a/messages.php b/messages.php index 1c8b47c7..4fc0abf3 100644 --- a/messages.php +++ b/messages.php @@ -47,7 +47,7 @@ require 'scripts/pi-hole/php/header_authenticated.php'; - + - - + + 0) { - - + + - + diff --git a/scripts/pi-hole/php/footer.php b/scripts/pi-hole/php/footer.php index c4ca7a1d..e96cf20a 100644 --- a/scripts/pi-hole/php/footer.php +++ b/scripts/pi-hole/php/footer.php @@ -102,6 +102,6 @@ if (isset($core_commit) || isset($web_commit) || isset($FTL_commit)) { - + diff --git a/scripts/pi-hole/php/func.php b/scripts/pi-hole/php/func.php index ef1a514b..a36cdba7 100644 --- a/scripts/pi-hole/php/func.php +++ b/scripts/pi-hole/php/func.php @@ -111,6 +111,19 @@ function checkfile($filename) return '/dev/null'; } +// Avoid browser caching old versions of a file, using the last modification time +// Receive the file URL (without "/admin/"); +// Return the string containin URL + "?v=xxx", where xxx is the last modified time of the file. +function fileversion($url) +{ + $filename = $_SERVER['DOCUMENT_ROOT'].'/admin/'.$url; + if (file_exists($filename)) { + $ver = filemtime($filename); + } + + return $url.'?v='.$ver; +} + // Credit: http://php.net/manual/en/function.hash-equals.php#119576 if (!function_exists('hash_equals')) { function hash_equals($known_string, $user_string) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index ddfe5af7..e0619177 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -1,9 +1,6 @@ - - + + - + - + - - - + + + - - + + - - - + + + - - + + - + - - - - + + + + - - - - - - - + + + + + + + - - + + diff --git a/settings.php b/settings.php index 7ff980f6..f024b894 100644 --- a/settings.php +++ b/settings.php @@ -1462,8 +1462,8 @@ if (isset($piholeFTLConf['RATE_LIMIT'])) { - - + + Automatic scrolling on update - + Automatic scrolling on update - +