Add cache-control headers to sendJSONresponse (#2234)
This commit is contained in:
parent
768a7b0ecb
commit
5df1850847
|
@ -1120,6 +1120,18 @@ sub sendJSONresponse {
|
|||
my ( $self, $req, $j, %args ) = @_;
|
||||
my $res = Lemonldap::NG::Common::PSGI::sendJSONresponse(@_);
|
||||
|
||||
# Handle caching
|
||||
if ( $args{ttl} and $args{ttl} =~ /^\d+$/ ) {
|
||||
push @{ $res->[1] },
|
||||
'Cache-Control' => 'public, max-age=' . $args{ttl};
|
||||
}
|
||||
else {
|
||||
push @{ $res->[1] },
|
||||
'Cache-Control' => 'no-cache, no-store, must-revalidate',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0';
|
||||
}
|
||||
|
||||
# If this is a cross-domain request from the portal itself
|
||||
# (Ajax SSL to a different VHost)
|
||||
# we allow CORS
|
||||
|
|
Loading…
Reference in New Issue
Block a user