rejetto forum

Controlling the Cache-Control header

0 Members and 1 Guest are viewing this topic.

Offline Smile4ever

  • Occasional poster
  • *
    • Posts: 5
    • View Profile
Hi. I would like to set Cache-Control to "Public" instead of the default "no-cache, no-store, must-revalidate, max-age=-1".

I tried Other options -> Edit event scripts with this:
[request]
{.add header|Cache-Control: Public.}

But it doesn't work. What did I do wrong?


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Unfortunately since several versions, Rejetto has deleted an extension of the ADD HEADER macro to add an option to an existing header. The addition of this macro in the [request] section has no direct effect on the MAIN section of template. To do this, you must take the default values and add it directly to the template

Quote
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
{.add header|Cache-Control: no-cache, no-store, must-revalidate, max-age=-1, public.}

.... the rest of template

In the model there are four sections containing DOCTYPE html, it will then be necessary to add the macro to each


Offline Smile4ever

  • Occasional poster
  • *
    • Posts: 5
    • View Profile
Thanks for your reply. I tried adding {.add header|Cache-Control: no-cache, no-store, must-revalidate, max-age=-1, public.} after each </head> but it didn't work, the default Cache-Control value is still used. I also tried {.add header|Cache-Control: Public.} but that didn't work either. I even closed and restarted HFS to no avail.

A workaround (using the older version of HFS) is welcome too, if you know enough details.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
I checked that 'public' was present in the answer using HTTPFOX plugin in Firefox, so if your browser does not respond correctly, either it does not fit or it conflicts with another value By default. Reduce the number of values to detect a possible conflict in Cache-Control

The macro in its form is sufficient, a later version will not bring a better result

What's different with the old version was the use of the macro in the form to add a header element without deleting its contents

{.add header|Cache-Control: Public|overwrite=0.}
 overwrite not working since several build and is true (1) by defaut and is ignored in the macro
« Last Edit: August 26, 2017, 05:09:10 PM by Mars »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Si je me fie à  google, j'ai bien à faire à une personne en belgique ou utilisant un proxi de ce pays?


Offline Smile4ever

  • Occasional poster
  • *
    • Posts: 5
    • View Profile
Quote
I checked that 'public' was present in the answer using HTTPFOX plugin in Firefox, so if your browser does not respond correctly, either it does not fit or it conflicts with another value By default.
I first used Firefox but tried SeaMonkey as well (+HttpFox), putting {.add header|Cache-Control: no-cache, no-store, must-revalidate, max-age=-1, public.} just before </head> three times (three occurences of </head>). It still returns Cache-Control "no-cache, no-store, must-revalidate, max-age=-1".

Quote
Reduce the number of values to detect a possible conflict in Cache-Control
What do you mean?

Quote
Si je me fie à  google, j'ai bien à faire à une personne en belgique ou utilisant un proxi de ce pays?
<s>I don't know why you're writing to me in French. French is not my native language (Dutch is) and my understanding of and my fluency in the English language is better :) If you know how to speak Dutch you're welcome to do so.</s> I just read your signature so I understand it now.

I don't understand exactly what you mean by this. I'm not behind a proxy.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
I don't understand exactly what you mean by this. I'm not behind a proxy.

It is because your IP that is accessible to me situates you in Belgium, which could lead me to suppose that you could speak French

Reduce the number of values to detect a possible conflict in Cache-Control

{.add header|Cache-Control: public.}

{.add header|Cache-Control: no-cache, no-store, must-revalidate, max-age=-1, public.}

add individualy each values to see the different effects

see http://www.i18nguy.com/markup/metatags.html or help on other pages
« Last Edit: August 26, 2017, 05:31:57 PM by Mars »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
When using FIREFOX, it's possible to retrive cache information by using  about:cache as url




Quote
How to turn off the Firefox cache?
Turn off the caching for a particular page. the correct way is to set the cache directive in Http request:

Cache-Control: no-cache

turn the entire Firefox caching capability off through its about:config page

network.http.use-cache = false.


the best way is probably to click on TOOLS in firefox and start private browsing which does not cache any pages and will restore any pages you had open prior to going in to PRIVATE BROWSING.

You will certainly find more information about different combination to manage Cache-control at this address
https://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers

Unfortunately I am at the limit of my knowledge on this point, all that I put before is extracted from a google search

Keep us informed of the success of your research
« Last Edit: August 26, 2017, 06:03:19 PM by Mars »


Offline Smile4ever

  • Occasional poster
  • *
    • Posts: 5
    • View Profile
Quote
It is because your IP that is accessible to me situates you in Belgium, which could lead me to suppose that you could speak French
For your information, only the lower half of Belgium speaks natively French. :)

I actually want the content to be ALWAYS cached, no matter what. That's what Cache-Control "Public" is for. I don't see Cache-Control "Public" anywhere after adding it to the template.

I looked at about:cache and it has no entry for that URL. The url I'm using is http://localhost:8080/wallpapers/?tpl=list&folders-filter=\&recursive


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
For your information, only the lower half of Belgium speaks natively French. :)
And those of that half who know him refuse to use it to differentiate themselves from their compatriots of the south  ;D ;D
...........................................................................................
No-cache and  no-store  must be removed

{.add header|Cache-Control: must-revalidate, max-age=-1, public.}

public necessary must appear in the header


Offline Smile4ever

  • Occasional poster
  • *
    • Posts: 5
    • View Profile
Quote
And those of that half who know him refuse to use it to differentiate themselves from their compatriots of the south  ;D ;D
Something like that ;)

Quote
{.add header|Cache-Control: must-revalidate, max-age=-1, public.}
This doesn't work either.

I have written my own PHP file to list files recursively. It performs the same task in about ~50ms instead of 800+ ms. The PHP file is hosted by the built in PHP server and acts as a proxy to HFS (the files themselves are still hosted on HFS).

I'm giving up on setting Cache-Control, since I have created a workable solution.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile

Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
Throwback for HFS 2.3 has used headers like these:
main
{.add header|Cache-Control: public, max-age=200.} and this <meta http-equiv=CACHE-CONTROL content=PUBLIC>

error messages and upload
{.add header|Cache-Control: no-cache, max-age=0.} and this <meta http-equiv=CACHE-CONTROL content=no-Cache>

See how they are equal yet opposite?  The 'mirror image' commands are necessary for the countermand/override concept to work. 
This is more common with style = old-way; new-way, and in that order; so, the browser gets as far as it can go.  The concept is actually the same.


For HFS2.4 there was slight difficulty in caching main page and then not caching login-name (some odd battle).   And, I know that those meta tags aren't right for XHTML nor HTML5 (those metas need a wee update).  Also there is no </meta> thus no /> because meta are not closable.
I got the caching to work for HFS2.4 with some experiments.  Somehow, the old style %login-link%%loggedin%%upload-link% was resistant to caching (some difference), so, it didn't cache wrong login data.  Would be nice if I had done that on purpose.  Unfortunately, I don't know how to repeat that yet.  Will investigate.


Usually there is no problem, with turning caching on--the problem is turning it off, such as for new folder (make it show) and login name (change when login) because the file-list page which should be cached (for a couple of minutes), also should change if new folder or login difference.  Very puzzling! 

I can report that caching headers work and that the problem of mixed data-to-cache + data-not-to-cache on the same page is not specific to HFS.
« Last Edit: August 01, 2020, 12:17:34 PM by danny »