getkirby / staticache

Static site performance on demand
MIT License
90 stars 9 forks source link

Deny direct browser access to `/static` URLs / different cache folder #4

Closed sebastiangreger closed 1 year ago

sebastiangreger commented 2 years ago

Should the /static folder be blocked from direct access via URL? (…either a .htaccess file in that folder or instructions in Readme)

Reasoning:

…or maybe this folder should be placed under site/static or even site/cache/static in the first place, to take it out of public reach and semantically make it part of Kirby's "internals"?

bastianallgeier commented 2 years ago

I think you are right. It would be kind of cool to have a redirect rule for everything in the static cache. I.e. in case you hit /static/photography/index.html you get redirected to /photography.

I also thought about putting it in the site folder, but that's less flexible when you want to use a public folder setup.

iskrisis commented 2 years ago

This would also fix blocking /static as possible Page in Kirby. Problem i had with /media in the past. Now that i think about it i should have fixed these /media issues in similar way by moving it out of public and making redirect.

bastianallgeier commented 2 years ago

I guess it would be best to have a configurable root option for the static cache. Then you could decide for yourself where it should be living.

iskrisis commented 2 years ago

@bastianallgeier should it be new root option when you already have to set it up in config.php? Shouldn't it live there?

bastianallgeier commented 2 years ago

@iskrisis not sure what you mean

iskrisis commented 2 years ago

@bastianallgeier I think i misunderstood i thought you want to make new $kirby->root('staticache') but you probably meant the same as me

  'cache' => [
    'pages' => [
      'active' => true,
      'type' => 'static',
     `root`=> '/yady/dada`
    ]
  ]

Anyway personally i like putting it somewhere into $kirby->roots('cache') by default. As @sebastiangreger proposed.

lukasbestle commented 2 years ago

I like the idea to put it in site/cache. Also fits from the semantics. The root could still be overridden by those who use a public folder setup.

lukasbestle commented 1 year ago