From 266f677f3bca76c41efae4ce5532d694472666d4 Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Wed, 7 Oct 2020 17:52:31 +0100 Subject: [PATCH 1/4] fix: minimal guide for static assets --- README.md | 2 +- static-assets.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 static-assets.md diff --git a/README.md b/README.md index 0e352d93..8b340b2a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ with only a subset of sections having recommendations): * Transactions_handling * Development - * Static Assets + * [Static Assets](./static-assets.md) * Keeping up to date * Code Quality * [Code Consistency](./docs/development/code-consistency.md) diff --git a/static-assets.md b/static-assets.md new file mode 100644 index 00000000..0409e24d --- /dev/null +++ b/static-assets.md @@ -0,0 +1,19 @@ +## Static assets + +For serving static resources we recomend using `express.static` middleware. +Using express.static() method, you can server static resources directly by specifying the folder name where you have stored your static resources. +Documentation for the middleware can be found in: + +https://expressjs.com/en/starter/static-files.html + +## Caching + +The static middleware does no server-side caching. +It lets you do two methods of client-side caching: ETag and Max-Age +If you configured your static middleware to use client side caching please make sure that +every modification in your code is represented as different file name. + +When using bundlers you will explicitly need to generate different file names every time content changes. +Example for webpack (most popular bundler) can be found here: + +https://webpack.js.org/guides/caching \ No newline at end of file From dbf23524993776a98a6b309a4c7d26d4a892fa7c Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Fri, 9 Oct 2020 23:01:12 +0100 Subject: [PATCH 2/4] fix: migrate to proper format --- static-assets.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/static-assets.md b/static-assets.md index 0409e24d..9f80aead 100644 --- a/static-assets.md +++ b/static-assets.md @@ -1,17 +1,24 @@ ## Static assets -For serving static resources we recomend using `express.static` middleware. -Using express.static() method, you can server static resources directly by specifying the folder name where you have stored your static resources. -Documentation for the middleware can be found in: +## Recommended packages + +* [express-static](https://expressjs.com/en/starter/static-files.html). +Express static is part of the express.js package that allows evelopers to expose static middlewares. + +## Guidance +For serving static resources we recomend using `express.static` middleware as it has been widely used and tested in production. +When using express.static() method, we can server static resources directly by specifying the folder name where we have stored our static resources. + +Documentation for the middleware can be found in: https://expressjs.com/en/starter/static-files.html -## Caching +### Caching -The static middleware does no server-side caching. +The static middleware does server-side caching. It lets you do two methods of client-side caching: ETag and Max-Age If you configured your static middleware to use client side caching please make sure that -every modification in your code is represented as different file name. +every modification in your code will be creating resources with different file name. When using bundlers you will explicitly need to generate different file names every time content changes. Example for webpack (most popular bundler) can be found here: From 65e6ef5b944653397448e4b9b6758dcb7c9bac47 Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Tue, 10 Nov 2020 12:19:29 +0000 Subject: [PATCH 3/4] fix: move static assets documentation into right directory --- README.md | 2 +- static-assets.md => docs/functional-components/static-assets.md | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename static-assets.md => docs/functional-components/static-assets.md (100%) diff --git a/README.md b/README.md index 8b340b2a..73133235 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ with only a subset of sections having recommendations): * Transactions_handling * Development - * [Static Assets](./static-assets.md) + * [Static Assets](./docs/functional-components/static-assets.md) * Keeping up to date * Code Quality * [Code Consistency](./docs/development/code-consistency.md) diff --git a/static-assets.md b/docs/functional-components/static-assets.md similarity index 100% rename from static-assets.md rename to docs/functional-components/static-assets.md From 5d8825cced04fbe6e9ac2beab15c4efc24fb0c6c Mon Sep 17 00:00:00 2001 From: Wojtek Trocki Date: Wed, 11 Nov 2020 16:13:13 +0000 Subject: [PATCH 4/4] Update docs/functional-components/static-assets.md Co-authored-by: Carlos Santana --- docs/functional-components/static-assets.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/functional-components/static-assets.md b/docs/functional-components/static-assets.md index 9f80aead..c9894a1e 100644 --- a/docs/functional-components/static-assets.md +++ b/docs/functional-components/static-assets.md @@ -3,7 +3,7 @@ ## Recommended packages * [express-static](https://expressjs.com/en/starter/static-files.html). -Express static is part of the express.js package that allows evelopers to expose static middlewares. +Express static is part of the express.js package that allows developers to expose static middlewares. ## Guidance @@ -23,4 +23,4 @@ every modification in your code will be creating resources with different file n When using bundlers you will explicitly need to generate different file names every time content changes. Example for webpack (most popular bundler) can be found here: -https://webpack.js.org/guides/caching \ No newline at end of file +https://webpack.js.org/guides/caching