Empty pragma heading for CSS styles.php

Empty pragma heading for CSS styles.php

by Gareth J Barnard -
Number of replies: 5
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello,

In relation to MDL-48023 I went off to fix the Essential theme and noticed an empty 'Pragma' heading that came from code I adapted from lib/csslib.php.  So... given: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html sections 14.9 and 14.32 can anybody explain why 'Pragma' is blank here: https://github.com/moodle/moodle/blob/master/lib/csslib.php#L297 and in functions below?

Just curious smile

Cheers,

Gareth

Average of ratings: -
In reply to Gareth J Barnard

Re: Empty pragma heading for CSS styles.php

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Interestingly been testing and found that when absent then 'Pragma: no-cache' is put in the headers.

In reply to Gareth J Barnard

Re: Empty pragma heading for CSS styles.php

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Gareth,
it depends on the web server hosting the Moodle instance e.g. session_cache_limiter().

BTW, Pragma: is almost the HTTP/1.0 equivalent for Cache-Control: public; in HTTP/1.1. Cache-Control gives fine tuning about what/how caching mechanism should take place.
no-cache is the only directive really implemented in HTTP/1.0.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Empty pragma heading for CSS styles.php

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Matteo,

Thank you for your reply.  I did not know about session_cache_limiter() - interestingly when I have:

header('Cache-Control: public, max-age=' . $lifetime);

and no 'Pragma' then the browser reports the headers sent containing:

Pragma: no-cache

Which is sort of contradictory given "HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client had sent "Cache-Control: no-cache" (14.32 of http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) .".  So I'm still not sure why you have to:

header('Pragma: ');

To bank it out for PHP,

In the past I have used Pragma headers to convey information to the client jQuery code from a bespoke Java web server because of the purpose of that header.  Being "Pragma general-header field is used to include implementation- specific directives that might apply to any recipient along the request/response chain" (14.32 of http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).

Cheers,

Gareth


In reply to Gareth J Barnard

Re: Empty pragma heading for CSS styles.php

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Gareth,
apologies for my late reply.
If you don't want PHP to add the cache HTTP Headers for you, you need to pass an empty string to the function above or to change your session.cache_limiter in php.ini.

I'm assuming that forcing "empty" HTTP Headers in the code was coded to give the Developer the option to overwrite this default behavior. Refs.:

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

Re: Empty pragma heading for CSS styles.php

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Matteo,

Sorry for the very late reply.  Thank you for the useful information.  The solution has to be a PHP one as it is a part of the Essential theme LTR / RTL switching CSS serving mechanism.

Cheers,

Gareth