I have around 2mb of static data around 2000 records (let’s say product information) which rarely changed.
I need this data in most of my pages, what is the better way to load this data?
I can think of 3 ways
-
Saving data in collection
- Can’t waste db operations and memory, they are expensive
-
Save data in json object in client side
- I feel this will increase the size of bundle and will increase the loading time for initial users
-
CDN
- I feel this is the better way to do, can we serve json object using cdn?
Any one other approaches to do this? Is CDN the best option?
You could implement a caching layer in the publication which you can invalidate on product insert/update.
I think this is the best bet. If you don’t want to go straight to a CDN you can also use a filesystem like S3.
Definitely. It’s not exactly the same but you can import bootstrap from a CDN.
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
No reason why you couldn’t serve a json file from a CDN.