Cache of page/index/index.js and MediaSelector

Enonic version: 7.0.2
OS: Ubuntu 19

Not sure what should the title be but, what is happening is. When I create a content-type with MediaSelector like this one:

<content-type xmlns="urn:enonic:xp:model:1.0">
  <description>Place where many people live</description>
    <input type="GeoPoint" name="location">
      <occurrences minimum="1" maximum="1"/>
    <input type="Long" name="population">
      <occurrences minimum="0" maximum="1"/>
    <input name="fil" type="MediaSelector">
      <occurrences minimum="0" maximum="1"/>

And then I throw this code right at the start of my page index.js, exports.get:

var content = portal.getContent()

if ( {
    var url = portal.pageUrl({
        type: 'absolute'
    return {
        status: 301,
        headers: {
        Location: url

It return me the file selected in the content-type, but after that it doesn’t matter if I remove the file from the content, remove this code from the index.js or remove the input from the content.xml it still return me the file. However if I access this content from another browser it give me the correct page (without the file). So my question is, how do I avoid caching all that?

I think your browser caches 301, since it is a permanent redirect. Try using 302 instead, or set http No cache headers


Oh now I feel silly for posting that. But thanks a lot, that solved it.