$h4X4_|=73}{ has asked for the wisdom of the Perl Monks concerning the following question:

How would you add in "Cache-Control: " and "Access-Control-Allow-Origin:" to CGI header?

use CGI qw(:standard); $CGI::POST_MAX = 1024 * 100; $CGI::DISABLE_UPLOADS = 1; my $query = new CGI; print $query->header( -expires => 'now', -cache => 1, # HTTP/1.0 );

Replies are listed 'Best First'.
Re: CGI.pm header
by stevieb (Canon) on May 24, 2016 at 16:13 UTC

    Does this work?

    print $query->header( '-Cache-Control' => $cache_val, '-Access-Control-Allow-Origin' => $origin_val, ..., );

      Yes it works. But there could be a new problem. Some for the names print out lower case in my tests.

      Expires: Tue, 24 May 2016 16:19:07 GMT Date: Tue, 24 May 2016 16:19:07 GMT Access-control-allow-origin: 2 Cache-control: 1 Cache: 1 Content-Type: text/html; charset=ISO-8859-1

      Do you think that will cause a problem?

        I honestly have no idea. Does it work when you test it?