hammady / wwpray

A website that shows the prayer times for a preconfigured list of masjids in a tabular format. Visitors can subscribe for email notifications.
https://wwpray.net
MIT License
1 stars 0 forks source link

Host static site using CloudFront #7

Closed hammady closed 1 year ago

hammady commented 1 year ago

Determine paths to cache.

hammady commented 1 year ago

@fayez-nazzal please explain the role for each generated file and suggest files that can be safely deleted.

hammady commented 1 year ago

Also we should only cache the immutable folder, right?

fayez-nazzal commented 1 year ago

@hammady

The generator output is taken from SvelteKit's static adapter. We are currently passing default options. There is also support for separating assets or compressing them with brotli and gzip, but it's irrelevant at the moment.

The build directory is minimal. Let me explain it ( I copied some content here from one of my blog drafts ):

If you expand the content of the build directory, you will get a filesystem tree similar to the following:

 ├── _app
 │   ├── immutable
 │   │   ├── assets
 │   │   │   ├── [..].css
 │   │   ├── chunks
 │   │   │   ├── [..].js
 │   │   ├── entry
 │   │   │   ├── [..].js
 │   │   └── nodes
 │   │       ├── [..].js
 ├── favicon.png
 ├── index.html
 ├── __data.json
 ├── other_route_example.html
 ├── other_route_example
           └── __data.json

Our whole app turned into HTML, CSS, JavaScript, and a few JSON files storing already fetched data. No trace of a single Nodejs function!

hammady commented 1 year ago

I have modified the generator code in 615085fc5c38fc8d5dea59c6387709501cbf516f to only copy index.html, favicon.png and _app to the destination folder. I don't think others are needed after the static generation. I viewed the source of the HTML to double check.

hammady commented 1 year ago

Also caching will be handled by CloudFront.

fayez-nazzal commented 1 year ago

@hammady The content of __data.json files is integrated into the HTML file in the last stages of the build process. I think it's safe to omit it. The only concern is that we may have more routes (and possibly static files) as we move on. How are we going to handle this?

hammady commented 1 year ago

YAGNI.