Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Trying to implement a cache strategy

Started by Muut Archive 10 years ago · 3 replies · 479 views
10 years ago

Hello everyone ♪

I am trying to implement a cache strategy according to this part of refering article.

The idea is to have a page set to no cache, then, according to the schema, to have particular URLs for CSS, JS, and MEDIA.

In system.yaml, this is giving:

YAML
pages:
  ....
  types: [txt,xml,html,htm,json,jsonld,rss,atom]
  ...
  last_modified: true       # Set the last modified date header based on file modifcation timestamp
  etag: true                     # Set the etag header tag
  ...
  expires: 0                     # Page expires time in seconds (604800 seconds = 7 days)

cache:
  enabled: true               # Set to true to enable caching
  check:
    method: file              # Method to check for updates in pages: file|folder|none 
  driver: auto                 # One of: auto|file|apc|xcache|memcache|wincache
  prefix: 'g'                     # Cache prefix string (prevents cache conflicts)
  lifetime: 31536000      # Lifetime of cached data in seconds (0 = infinite)
  gzip: true                   # GZip compress the page output

....

assets:                        # Configuration for Assets Manager (JS, CSS)
 ....
  enable_asset_timestamp: true      # Enable asset timestamps

images:
  cache_all: false          # Cache all image by default

media:
  enable_media_timestamp: true     # Enable media timestamps

Points are:

YAML
pages:
  expires: 0

because 0 seconds is different from no-cache.

So question:
is this strategy (with above settings) is possible?
is 0 seconds a suitable or should I make a issue to ask for a nex parameter?

Thanks in advance for taking time for this ☆

10 years ago

Addition to previous post:

I need also to know how to set cache-control status private like in reference Cache-Control: private, max-age=3156000

Thanks

10 years ago

Grav's cache preference is pretty poorly documented IMO, but it doesn't control HTTP caching - but rather "page caching" on the server. If you want to control the HTTP caching, you should specify that in your webserver config. HTML5 boilerplate has some good defaults here https://github.com/h5bp/server-configs

10 years ago

Thanks you very much for your answer: it's a lot clearer for me now.
I could not figure that difference between cache of page and cache of http

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1359 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2955 9 years ago
Archive · by Muut Archive, 9 years ago
3 1121 9 years ago