Comments (5)
\FluidTYPO3\Vhs\Middleware\AssetInclusion::class should be registered to be executed AFTER 'typo3/cms-frontend/content-length-headers'
That sounds quite wrong to me. I'm not sure that's actually the case - if that were so, then TYPO3 would be out of the box configured to do output compression on content, before the content is created; and do site-resolving after the page has been resolved. As far as I am aware, TYPO3 will process every middleware in their defined order (it will not switch order of the last "chunk" of middlewares after a certain point). So when you register a middleware to come before something else, then that middleware will be processed before the relative middleware.
It is however possible that config.enableContentLengthHeader
somehow changes when the content length calculation happens so it no longer happens in the content-length-headers
middleware, that it calculates length on an older version of the output string, or that VHS's calcualted content length is somehow overwritten.
from vhs.
Hi @NamelessCoder,
it's quite puzzling. The last few days I had some troubles to get used to the way, TYPO handles the order inside the middleware stack. Within the registration, "before" actually means, that the referenced middlewares must be executed before the currently registered middleware. And "after" means, the referenced middlewares must be executed after it.
It's a bit cryptically worded, but one may read it here: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/RequestLifeCycle/Middlewares.html#configuring-middlewares
In my current project I found that using this registration of the VHS middlewares does the trick:
return [
'frontend' => [
'fluidtypo3/vhs/asset-inclusion' => [
'target' => \FluidTYPO3\Vhs\Middleware\AssetInclusion::class,
// 'before' => [
// 'fluidtypo3/vhs/request-availability',
// ],
'after' => [
'typo3/cms-frontend/content-length-headers',
'typo3/cms-frontend/output-compression',
],
],
'fluidtypo3/vhs/request-availability' => [
'target' => \FluidTYPO3\Vhs\Middleware\RequestAvailability::class,
'before' => [
'typo3/cms-core/normalized-params-attribute',
],
],
],
];
With this config, content-length headers get produced after the assets have been inserted. Works like a charm... And: No need for VHS extension to do the content-length calculation on its own or to disable those headers.
from vhs.
@tastendruecker Would you mind going to the "Configuration" module in your TYPO3 install and selecting the "PSR-15 Middlewares" category, expand the "frontend" section and grab a screenshot for me? I'm really curious how that configuration makes the middlewares array look. On my system(s) the VHS asset middleware sits before the content-length and output-compression middlewares and when those are iterated, that would (afaics) cause the processing to happen in the right order. If those are sorted differently on your system and it causes the right behavior then I'm really at a loss as to what's going on.
Before: List of middleware identifiers. The middleware itself is executed before any other middleware within this array.
This means the exact opposite of "the middlewares in this array must be executed before the current middleware".
From what I read in the documentation: if I configure content-length and output-compression in the "before" array, then that means the VHS asset inclusion must happen before those two. In human words the current configuration reads as and means: "VHS asset inclusion must happen before content length is calculated and before output compression happens" - and that is 100% correct.
There just has to be some kind of side effect which coincidentally is making this work on your system with an intentionally wrong configuration.
from vhs.
Hi @NamelessCoder,
sure, this is the middleware stack of my project:
If you take a tool like xdebug and set breakpoints at the return statements of the registered middlewares' process() methods, you may see the order in which they are executed: First one is TYPO3\CMS\Core\Middleware\ResponsePropagation
, last one is TYPO3\CMS\Frontend\Middleware\TimeTrackerInitialization
, at least in my project ;-)
Additionally, the PHPDoc comments of methods add()
and lazy()
of TYPO3\CMS\Core\Http\MiddlewareDispatcher
state that the stack gets executed "last in, first out".
I suppose, this is no kind of side effect, but the documentation is misleading. Just my 2 cents...
from vhs.
The confusion stems from the fact that middlewares are executed in the order they are configured, so the before
and after
instructions do work the way the configuration states. But most middlewares work by calling $handler->handle($request);
as the first line. Middlewares therefore have two methods of operation:
- They can execute things before the next neighbor.
- Or they can execute things after the next neighbor.
(TimeTrackerInitialization does both: sets the timer, then executes the next - and next, and next, etc. - middlewares and reads the timing result after, before finally returning - and VHS's other middleware executes things before the next neighbor).
When they execute things after the next neighbor that gives the effect that the stack is processed "in reverse" (it isn't really, though): the middleware that comes before another, executes the middleware that comes after. This is to say that it's actually not an effect of the stack itself - it's an effect of how each item in the stack operates.
But it is true that this means the first thing VHS does in the asset inclusion middleware is execute the content-length middleware which is indeed the wrong order. What we want instead is for the content-length middleware to execute VHS asset inclusion (or another middleware that then executes VHS asset inclusion) first and then assign its content-length header. But this is not because the stack is executed in reverse - it's because the content-length middleware executes the next neighbor before doing it's own operation.
from vhs.
Related Issues (20)
- PHP deprecation warning on missing canvasColor
- BUG: v:render.request causes error 'Cannot instantiate interface ConfigurationManagerInterface'
- BUG: v:page.menu.directory problem HOT 1
- TYPO3 10.4 throws TypeError
- v:content.render influences action uri generation HOT 2
- BUG: compatibility issue with TYPO3 12.4.7
- BUG: Image Srcset wrong url encoding HOT 1
- (Possible) BUG: with media.image when NO "format" argument is given
- BUG: Breaking change for flagSrc and unexpected value (LanguageMenu)
- DEPRECATION in TYPO3v12: SiteLanguage->getTwoLetterIsoCode()
- BUG: When VHS is installed using redirect in controller does not work without extensionName argument HOT 11
- BUG: Exceptions when using UncacheViewHelper on TYPO3 12 HOT 10
- f:format.replace does not work if used in inline syntax
- BUG: MenuViewHelper will not translate one single page - v 7.0.1
- BUG: View helper result only available in child tags since 7.0.0 HOT 4
- BUG: problem with php-warning in AbstractContentViewHelper in version 6.1.3 HOT 6
- TYPO3 13 compatibility HOT 2
- BUG: no request object in v:render.template
- was "classHasSubpages" removed from v:menu on version 7.* HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vhs.