An Overview of Caching Methods
- Two main caching categories
- time base
- content base
14 Jan 2019
- Caching challenges
- Expire by time
- Expire by update
- Common cache methods
- Browser caching
- It talks about HTTP cache header, re-read when needed
- Application-level cache
- In memory cache for slow functions
- Key-value data caching
- Centralized cache like Redis
- Browser caching
What’s Next? Exploring the future of React, now
This video talk about design concept of Next.js
- Static is a subset of dynamic
- Will have less powerful machine to code -> defer build to cloud
- Send manifest only not built files -> dev machine network is not good enough
- Reduce dependency, config the pipeline for you
- Code sharing between back end and front end is impossible. Backend render some HTML and front end take over the rendering
- React lifecycle concept help universal rendering
- separate data and render logic (next add a get init prop hook for server side rendering, so the component can be reused in backend and frontend)
- Each page is individual, no default common header and footer
HAProxy从零开始到掌握
- Load balancer
- Provide L4 (TCP) and L7 (HTTP) load balancing
- Support different load balance hash algo
- Rewrite cookies
- URL redirect
- Parse SSL, redirect HTTPS to server as HTTP
- Monitor and stats
Recommendation system
Collaborative filtering
- Cluster user -> give suggestion base on the action of user in the same cluster
- Don’t need to understand the semantic of the action, just send the recommendation base on similar user’s action
- Have open source solution
- Require ppl with data mining knowledge
- Difficult to evaluate cluster performance
- Need someone to interpret the user cluster
- Need time to build up recommendation of new object (need to wait user reaction)
Content based - Build user profile by user history, find recommendation base on user profile
- Build recommendation quicker, don’t need to wait user
- User profile easier to understand
- Don’t need data mining?
- Need NLP, add tags
- Build system to track tags
測試案例設計入門
- Balance quality, speed and cost
- Need to understand business use case to good test spec
- Test base on tech spec vs businesss
- Thoughts
- after we have separate the module for tech requirement and business requirement, it is easy to know which test to write
- unit test for technical requirement, integration test for business requirement
- They are not conflict, good spec should take care both business use case and tech spec
- Thoughts
- Test need to have priority
- V model
- Acceptance Testing
- Test do in early stage, not much tech details
- System Testing
- Involve more tech details
- We can use 等價類劃分法 and 邊界值分析 to define test cases
- Integration Testing
- No clear definition
- Unit Testing
- Test small units
- Useful during refactoring
- Acceptance Testing
- Select which platform to test
- 最舊的版本
- 最新的版本
- 最小的螢幕
- 最大的螢幕
- 最多人使用
- Pairwise Testing
- No idea what is it
- Test case order
- 新功能測試
- 回歸測試
- 探索測試
- 由tester隨心咁試
- 仰賴的是測試人員對於產品與技術的熟悉程度
- 探索測試
- 驗收測試
Reduced Test Cases
This article is focus on reduced test case for web page, but the principle can be apply to other area.
- A reduced test case is a demo/example page you create which reproduces the problem you are having with the least amount of code possible
- Help isolate the problem
- Easier for others to help you
- How to set up a reduced test case
- Make it static
- mock the dependencies (data, function call, 3rd party api, etc)
- Make it isolated
- Move the related codes to a separated project/repo
- Remove the code not related to the problem
- Document it
- Make it static
- You need to know the core problem, before asking for help
以下無需重讀
Maintaning more than 65535 connections on single IP
之前對socket有一個誤解:部機最多有65535個port,每一個connection要用一個port,咁一個server點同時handle到10k嘅connections?
解說:個server application只需要用一個port黎listen client,無論有幾多個connection連過黎,都只需要用一個port。反之,一個server每連出去外面一個application,就要用一個port,因此一部機最多連去65535部機。
How long do browsers cache HTTP 301s?
Avoid 301 cache, as it the cache default have no expire date.
Git hook (Lost the reference)
Hooks are local to git repo, will not be copy when clone repo
Local vs server-side hook
- Local hooks
- pre hooks let you alter the action
- post hooks only for notification
- Pre commit
- can use this to inspect the snapshot which is going to commit
- return non zero value abort the commit
- Prepare commit message
- A good place to alter the automatically generated commit messages for squashed or merged commits. (Auto correct spell check?)
- Commit message
- Call after user enter commit message
- Post commit
- Good place for notifying commit action to other server (send email to other after commit)
- Post checkout hook
- Good place for clearing out generated files in working directory to prevent confusion (dist/
- Pre rebase
- Good place to prevent user rebase branch
- Server side hooks
- Pre receive
- Call once when git push is executed
- Can reject user pushing bad commit
- Other commit use case
- Reject changes involve an upstream rebase
- Preventing non-fast-forward merges
- Checking user permissions
- Update
- It is execute for each branch push (a push can update multiple branches)
- Post receive
- Better place then post commit for notification, because the commit is public now
- Pre receive
- Seems there are also other hooks
Exceptions: Why throw early? Why catch late?
- Software layering provide key context on how you handle exception
- 3 ways to handle
- catch -> rethrow
- when you cannot handle the error
- you should add more information to help understanding the problem.
- catch -> handle
- when you can make the finial decision
- catch -> error return
- Prefer throw exception than return error
- catch -> rethrow
在壓力之下人要如何「防呆」?
- 所有講究精準的任務,在高度壓力下都會失焦
- 係高壓環境工作嘅專業人士有工種方法
- 壓力預防(stress inoculation)
- 反覆練習
- 金句
- Stressed is just desserts if you can reverse