2020/05/17

What Is The Difference Between Session, Cookie, SessionStorage and LocalStorage?




Type session cookie sessionStorage localStorage
Storage location Server-side Client-side Client-side Client-side
Maximum data size 1024KB 4K for one cookie, max 20 cookies for a website 5M 5M
Expired Time If the user doesn’t active for a long time which over expires time, the server-side will delete the session to save the space * Users can set the expiration time for each cookie.

* It will expire after closing the browser if it set on client-side
The data clear automatically when the browser is closed The data WILL NOT be deleted when the browser is closed until the user clear through JavaScript, browser cache / locally stored data
Scope No Changes made are saved and available for all same-origin page Changes made are saved and available for the current page Changes made are saved and available for all same-origin page
Security High Low Low Low
Usability Easy to use The API is difficult to use Has method setItem, getItem, removeItem, clear that easy to use
HTTP Request The data is sent back to the server for every HTTP request which causes performance problems The data is NOT sent back to the server for every HTTP request
Application Login Login, shopping cart, game scores Form Shopping cart
類型 session cookie sessionStorage localStorage
存儲 服務端 瀏覽器端 瀏覽器端 瀏覽器端
存儲容量 默認大小一般是 1024k 單個 cookie 保存資料不能超過4k,且很多瀏覽器限制一個網站最多保存20個 cookie 5M 5M
失效時間 設置一個失效時間,當距離客戶端上一次使用 session 的時間超過這個失效時間時,服務器就可以認為客戶端已經停止了活動,才會把 session 刪除以節省存儲空間 * 一般由伺服器生成,可設置失效時間。

* 如果在瀏覽器端生成Cookie,默認是關閉瀏覽器後失效
當前瀏覽器關閉前有效 始終有效,即使視窗或瀏覽器關閉也一直有效,除非用戶手動刪除,其才會失效
作用域 在所有同源視窗是共用的 不在不同的瀏覽器窗口中共用 在所有同源視窗是共用的
安全性 較高 較低 較低 較低
易用性 有很大的隨意性,可隨時呼叫,不需要開發者做精確地處理 原生 API 不如 storage 友好,需要自己封裝函數 Web Storage 擁有 setItem, getItem, removeItem, clear等方法
與伺服器端通信 每次都會攜帶在HTTP頭中,如果使用cookie保存過多資料會帶來性能問題 僅在用戶端(即瀏覽器)中保存,不參與和伺服器的通信
應用場景 將某些資料放入session中,供同一使用者的不同頁面使用 帳號登入、購物車、遊戲分數 表單頁面 購物車



2020/04/09

Suffering From Perpetual Fernweh




Have you ever have a feeling that you wanna go to a place that you can't describe by the words which cause you to feel pain?
Do you have a true desire in the deep bottom of your heart that you wanna go to every unknown place in the world?
Will you see a photo then you feel woe that you haven't gone to that place in person?

Yeah, there are a word to describe this feeling calls "Fernweh" in German, we can translate it roughly as "An ache for distant places", it's an opposite word against to homesick, homesick is a sickness that missing home, but how can I have a feeling missing a place I don't even know?

Judith Thurman has said, "Every dreamer knows that it is entirely possible to be homesick for a place you've never been to, perhaps more homesick than for familiar ground."

This author describes the "Fernweh" properly, and not only she has a feeling like this, but there is also another author said about this feeling.

"If I find in myself desires which nothing in this world can satisfy, the only logical explanation is that I was made for another world."
C.S. Lewis, Mere Christianity


I feel the pain that I wanna go to the place that I can't describe.
I have a true desire in the deep bottom of my heart that I wanna go to every unknown places in the world.
I feel woe that I see a photo that I haven't gone to that place in person.

I'm suffering from perpetual fernweh.


2019/07/04

還在考慮轉職工程師要上哪間學校? 這裡推薦你免費的學習資源、書籍與素材

在考慮轉職前建議你先看看這篇文章 為什麼我說不要轉職成工程師的七大原因


--
如果你有以下困擾,歡迎參考此篇文章 :

1.  我是初學者,有沒有推薦的學習資源
2.  有沒有推薦的書籍
3.  想去實體店面翻書,有沒有推薦的店家
4.  原文書很貴,想買又不確定適不適合自己
5.  有沒有論壇可以和大家互相交流
6.  我想要問問題,是要直接把程式碼貼上去問嗎
7.  切版很需要素材,有沒有推薦的網站


而網路上已經有很多為什麼要轉職前端工程師如何轉職成前端工程師的文章,這邊也有一篇 2021 年成為 Web 開發人員的路線圖 可以參考來決定方向 (每年會更新可以自己查閱),這邊就不複述了

這篇主要是寫給對於前端有興趣的「初學者」、「非本科想轉前端」的人,可以利用哪些網站來幫助自己學習;因為我個人是非本科轉前端,到現在差不多兩年多了,想分享些自己當初到現在用過覺得不錯的學習資源、書籍與素材

2019/02/10

把寵物留在你身邊 - 客製化寵物倉鼠骨灰耳環




我的黃金鼠 - 少糖,是在去年11月的時候去世的,在看醫生時就知道時間有限,所以在少糖去世那之前就已經考慮了很多種的方式安葬他;幸好那時候待業有全部的時間陪他,這真是我做過最不後悔的決定。

想過種在盆栽裡,撒在大草原上,或是找個具有紀念價值的地方埋起來,也有看到有人在做骨灰飾品。但因個人因素種在盆栽裡不好照顧,灑大草原和埋起來本來是想表示他之後可以無拘無束的奔跑了,但都沒有特別值得紀念的地方,而且有時候我會很想對他說說話,所以還是選擇了至少把骨灰留下來。

少糖對我來說有很特殊的意義,在很多艱難、痛苦的時刻,看到他在飛輪上跑就覺得心情好起來,一早起來也可以看到這隻可愛的小毛球在那活躍,是支持我過活和真正第一次養的寵物,走後好久我都會想跟他說說話,所以每天都在寫信給他,也很渴望能多一分鐘五分鐘讓我再抱抱他、摸摸他,到很久之後才接受這是不可能的..