Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

like filem for php, date of file save

Quote Reply
like filem for php, date of file save
Because of Safari i need a timestamp behind my linked css-file.
Any ideas how to?

I solved it like this:


Code:

sub {
#2019-10-11_02:01:59
#%04u-%02u-%02u_%02u:%02u:%02u

use strict;
use warnings;

my $file= "/... path .../app.css";


my @date=reverse((localtime(( stat $file )[9] ))[0..5]);
$date[0]+=1900;
$date[1]+=1;
my $output=sprintf('%04u%02u%02u%02u%02u%02u',@date);

return $output;
}

Last edited by:

Robert: Oct 11, 2019, 3:32 AM
Quote Reply
Re: [Robert] like filem for php, date of file save In reply to
Hi,

I'm not sure what you are trying to do ? Can you give an example of the desired output?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] like filem for php, date of file save In reply to
It is about visitors and their cache.
When i change my css-file, it is fresh loaded in my pc's browser, but not in my ipad. So i need to make the ipad reload the file, when i have updated it.

For this i use a global <%css%> in

Code:
<link rel="stylesheet" href="/.../app.css?v=<%css%>">

Code:

sub {
#2019-10-11_02:01:59
#%04u-%02u-%02u_%02u:%02u:%02u

use strict;
use warnings;

my $file= "/path-to-dir/app.css";


my @date=reverse((localtime(( stat $file )[9] ))[0..5]);
$date[0]+=1900;
$date[1]+=1;
my $output=sprintf('%04u%02u%02u%02u%02u%02u',@date);

return $output;
}


Everytime i have changed the css finally (after a day of work for example), i have to rebuild the whole page to have a new value behind the app.css?v=<%css%> and this is just what i want to have. Static work, no dynamic stuff.

The output looks like:
Code:
<link rel="stylesheet" href="/../app.css?v=20191014132745">

Last edited by:

Robert: Oct 17, 2019, 6:42 AM