blob: 325e6e5d411feb876994fec255777c81cb38a909 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
## Server-Client contract
Servers can serve content in 2 major formats: text/html and json (and links to many more content types)
Clients/browsers can handle content in many more ways; they can just passive render the content or they
can grow their proccessing and logic to become a smart engine or heavy application.
These 2 factors need to cooperate smoothly. So, it is necessary to pre-define:
- what a server serves
- what a borwser/client procceses
This contract:
- allows development sharing in separate teams
- sets clear rules for each development group
- helps developing an ecosystem of reliable tools that can be reused and extended
- helps to detect malfunctions and apply fixes and optimizations
- makes the project manageable and scalable
---
## The Contract
A cotract is recommended to include as less as possible rules;
Of course there might be page-types that need special handling; Such pages are
- product pages
- product categories pages
### Rule #1: Default rule
On the server side:
- Server serves main content in html format; all non-user-based content is constucted and served in html format
On the client side:
- Client/browser requests the user-based content via ajax; (*still to be determinid the format of the replies*)
### Product Pages
apache:
serves product -> product: { id, title, prices:{ s1:{..}, s2:{..}, ... }, images:{...} }
browser:
check cookie(store) = s#
-> use product.prices.s# to draw prices
---
|