Изменения

Перейти к: навигация, поиск

HMVC

1356 байтов добавлено, 11:11, 16 мая 2016
Новая страница: «Об одном правильном подходе к HMVC (Hierarchical MVC). == English == Our own HMVC. Each controller has 2 methods: * check() — always…»
Об одном правильном подходе к HMVC (Hierarchical MVC).

== English ==

Our own HMVC. Each controller has 2 methods:
* check() — always runs before trying to load the output from cache:
** handles modification requests (and redirects after applying changes),
** validates parameters, redirects to handsome URLs
** calculates cache key
** also it MAY calculate cache tags and do subrequests if it wants to
* run() — runs only on cache miss:
** calculates output HTML
** MAY calculate cache tags and do subrequests if check() does not want to :-)

Request workflow:
# Create main controller
# Create layout controller
# Starting with the main controller:
## Call check()
## Try to load output from cache
## If loaded and valid, and if check() did not call subrequest() — load subrequest records from cached output
## If not loaded:
### If check() calculated some cache tags — do NOT reset them
### Call run()
### Save output, tags and subrequest records to cache
## Do (3) with all subrequest controllers
## Replace placeholders in output with subrequest outputs
# Do (3) with the layout controller
# Calculate Last-Modified from cache tags of all controllers
# Compare Last-Modified with the requested If-Modified-Since and send HTTP 304 if not modified
# Send generated output normally

[[Category:Разработка]]

Навигация