[MAGNOLIA-4713] Uncached pages are sent with incorrect content-length response header Created: 05/Dec/12 Updated: 24/May/23 Resolved: 27/Feb/13 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | cache |
| Affects Version/s: | 4.4.9, 4.5.6 |
| Fix Version/s: | 4.5.8, 5.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Tom Wespi | Assignee: | Jaroslav Simak |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Tomcat 7 |
||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Template: |
|
||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||||||
| Date of First Response: | |||||||||||||
| Description |
|
This can be seen when sharing a page in Facebook, cached pages are working, while uncached pages cannot be retrieved by Facebook. Since FB is strict about how many bytes it reads from client. Try to share http://demopublic.magnolia-cms.com/demo-project.html |
| Comments |
| Comment by Tom Wespi [ 05/Dec/12 ] |
|
Use this tool to fetch a page like Facebook |
| Comment by Magnolia International [ 15/Jan/13 ] |
|
Another difference I've noticed is that a request with parameters (which may or may not be related to cache) does not have the Last-Modified and Content-Length headers that a request without parameters has. For some reason, on the other hand, Transfer-Encoding: chunked is present on the with-params request. |
| Comment by Jaroslav Simak [ 20/Feb/13 ] |
|
Setting flag wrapWriter to false caused that sharing is working. Here is code of the wrapWriter method: @Override
public PrintWriter getWriter() throws IOException {
if (!wrapWriter) {
return super.getWriter();
}
if (this.writer == null) {
this.writer = new PrintWriter(new OutputStreamWriter(getOutputStream()));
}
return writer;
}
|
| Comment by Jaroslav Simak [ 27/Feb/13 ] |
|
So in the end sharing problem is caused by response.setContentLength(range.lengthOfRange); in RangeSupportFilter. Removing it will "enable" facebook sharing. The problem is that content length is set to bigger value (512K) than real content length (xxK). This means that facebook is trying to download more content but nothing is coming to him. I hope my explanation is clear. curl --range 0-524287 -H "User-Agent: facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
Host: magnolia-cms.com
Accept: */*
Accept-Encoding: deflate, gzip
Range: bytes=0-524287
Connection: keep-alive
" http://demopublic.magnolia-cms.com/demo-project.html?test=test > fb_prob
Btw according to RFC it should fine to not set content-length if we don't know it. |