I'm building a guestbook in php. When I checked the page with a SEO-checker it said that I should set expires headers. It's the very first time I'm working with expires headers and I've tried adding them in the .htaccess-file which failed as neither mod_expires nor mod_headers is on on the server and I won't be able to change it. My question is, if there is a possibility to set these expires headers in my php code without having mod_expires or mod_headers on? If so, how would I have to implement it in my code so that it'll work? And if you want to give me the answer "with header(....)" please explain how to set this up and where to put this, I don't just wanna copy-paste code, I want to learn how to do it.
I would like to set expires headers for images (jpg/jpeg/gif/png) as well (if possible) for my stylesheet (css).
Down below I listed the questions on StackOverflow which I've already checked, but some of them are really hard to understand for a newbie like me or they never really get an answer. Some of them never say where to implement the code snippets, which makes it hard to use an accepted answer.
I'm very new with programming web-pages, so please write explanations why I should do what, so I'll learn it for the future. If you need any more information, please don't hesitate to write so in the comments. I'll try to answer whatever I can. Thank you.
(Already checked questions:
- Expires Headers Not Working
- Setup HTTP expires headers using PHP and Apache
- Add expires header without mod_expires?
- How do I configure apache - that has not got mod_expires or mod_headers - to send expiry headers?
- Apache: How to add Expires headers to files without mod_expires installed
- and some more...
)
PHP-Version: 7.0.10
(PS: I don't know why mod_headers and mod_expires aren't on, but I'm sure that the company won't change it just for my small project.)